[Python-Dev] map() methods (was: Re: [Patches] Review (was: Please review before applying))

Tim Peters tim_one@email.msn.com
Mon, 24 Apr 2000 20:56:18 -0400


[Guido]
> ...
> However, this is *still* not as powerful as
>
>   map(lambda s: s.strip(), L)
>
> because the former requires that all items in L are in fact strings,
> while the latter works for anything with a strip() method (in
> particular Unicode objects and UserString instances).
>
> Maybe Python 3000 should recognize map(lambda) and generate more
> efficient code for it...

    [s.strip() for s in L]

That is, list comprehensions solved the speed, generality and clarity
problems here before they were discovered <wink>.