[Python-ideas] More power in list comprehensions with the 'as' keyword

Georg Brandl g.brandl at gmx.net
Thu Aug 28 00:28:51 CEST 2008

Brett Cannon schrieb:

> And if you really want your one-liner, you can avoid your duplicate
> call to str.strip() in two different ways::
>   [line.strip() for line in text.splitlines() if line and not line.isspace()]
> or::
>   filter(None, (line.strip() for line in text.splitlines()))

And thank god we can finally write

map(str.strip, text.splitlines())

again in Py3k.


More information about the Python-ideas mailing list