Comments on Version 2, Draft Pep for Deprecating Builtins
holger krekel
pyth at devel.trillke.net
Mon Apr 29 13:12:04 EDT 2002
On Mon, Apr 29, 2002 at 01:40:18PM +0000, Duncan Booth wrote:
> > Btw, what is the best/shortest way to express 'filter' and 'reduce' with
> > list comprehensions?
>
> filter(fn, lst)
> becomes:
> [ v for v in lst if fn(v) ]
>
> filter(None, lst)
> becomes:
> [ v for v in lst if v ]
>
> If the second argument to filter is a string or tuple then you have to
> convert the resulting list back to the appropriate type:
>
> e.g.
> filter(fn, aString)
> str.join('', [ v for v in aString if fn(v) ])
You really feel that these free floating strings with
no clear separations and lots of micro-management where
you dont't even know what does what and where the parts
start to float around and you ask yourself
when the sentence will ever end
come even close to
filter(fn,list)
???
We must be living in different worlds, then.
Just because list comprehension is a useful tool
doesn't make it 'more readable' than the often
used filter/map/reduce functions.
This has *nothing* to do with lambda and its
reasons for existence and i would rather like
to keep the concerns separate.
holger
More information about the Python-list
mailing list