Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: [Python-ideas] iterable.__unpack__ method

Reply
Thread Tools

Re: [Python-ideas] iterable.__unpack__ method

 
 
Chris Angelico
Guest
Posts: n/a
 
      02-24-2013
On Mon, Feb 25, 2013 at 1:44 AM, Tim Chase
<(E-Mail Removed)> wrote:
> On 2013-02-25 01:19, Chris Angelico wrote:
>> >>> command, subcommand = next(iterargs), next(iterargs)
>> >>
>> >>
>> >> Err.... is there a language guarantee of the order of evaluation
>> >> in a tuple, or is this just a "CPython happens to evaluate
>> >> independent expressions left-to-right"? This is totally broken
>> >> if the next() calls could be done in either order.
>> >
>> > It's a language guarantee.
>> >
>> > http://docs.python.org/2/reference/e...aluation-order

>>
>> Ah, so it is. My bad, sorry! In that case, sure, this works. It
>> still violates DRY though, naming the iterable twice and relying on
>> the reader noticing that that means "take two off this one". But
>> that's a much weaker concern.

>
> Your DRY/readability concern might then be addressed by writing it as
>
> from itertools import islice
> # ...
> command, subcommand = islice(iterargs, 2)
>
> (sorry if this was already addressed in the python-ideas@ thread,
> since I'm not subscribed there and it looks like discussion migrated
> to python-list@).


Blargh, it didn't migrate, I just posted to the wrong list courtesy of
a typo. Sorry.

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
invoke a method by reflection£¨the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
BC30289: Statement cannot appear within a method body. End of method assumed. Carlos Oliveira ASP .Net 0 08-19-2004 07:51 PM
Difference between Delete method and RemoveRow method CW ASP .Net 0 04-01-2004 01:07 AM
ASP.NET: BC30289: Statement cannot appear within a method body. End of method assumed. Mike Wilmot ASP .Net 0 12-15-2003 07:49 PM



Advertisments