
Aug. 27, 2008
10:28 p.m.
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. Georg