List comprehensions' ugliness (Was: Re: How to explain exactly what "def" does?)

holger krekel pyth at devel.trillke.net
Wed Feb 5 15:29:18 EST 2003


Skip Montanaro wrote:
> 
>     >> So, when exactly is a list comprehension ugly? I use them a lot in
>     >> places where I used to use filter. For example:
>     ...
>     holger> To some of us the filter version reads much better.
>     holger> It actually tells exactly what is happening: 
>     holger> the 'foo' function filters out matching elements.
> 
> Doesn't it "filter in" matching elements?

Sure, that was a thinko.  But "filter on" makes even more
sense.  Anyway, it's isn't as nice to read list comprehensions:

    "every x for x in the list if x matches ..."

which is not a very object oriented concept (tm) to start with. 

Regarding you interesting theory about the PS





More information about the Python-list mailing list