List comprehensions' ugliness (Was: Re: How to explain exactly what "def" does?)
Gerrit Holl
gerrit at nl.linux.org
Wed Feb 5 11:59:26 EST 2003
Greg Ewing (using news.cis.dfn.de) schreef op dinsdag 4 februari om 00:32:39 +0000:
> List comps themselves aren't ugly, but abusing them
> for things like that certainly is! (And probably
> gives them a bad name.)
So, when exactly is a list comprehension ugly? I use them a lot in
places where I used to use filter. For example:
filter(foo, i) --> [i for i in l if foo(i)]
Is this abuse?
What is the correct use for list comprehensions and what isn't?
yours,
Gerrit.
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
More information about the Python-list
mailing list