Arnaud Delobelle a écrit :
> On Mar 13, 8:53 pm, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>> Paul Rubin a écrit :
> 
> [snip]
> 
>>>  Iterators like that are a new Python feature
>> List comps are not that new (2.0 or 2.1 ?):
>> print "\n".join([contact for name, contact in contacts.items() \
>>                   if search.match(name)])
> 
> You can write this, but:
>    * it is difficult to argue that it is more readable than Paul's (or
> my)  'imperative' version;

I personnaly find it more readable. To me, it tells what, not how.

>    * it has no obvious performance benefit,

No.

>>> and they have
>>> some annoying characteristics, like the way they mutate when you touch
>>> them.
>> While sequences are iterables, all iterables are not sequences. Know
>> what you use, and you'll be fine.
> 
> ...And know when to use for statements :)

Don't worry, I still use them when appropriate.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to