[Python-ideas] More power in list comprehensions with the 'as' keyword
BJörn Lindqvist
bjourne at gmail.com
Wed Aug 27 20:21:09 CEST 2008
2008/8/27 Tarek Ziadé <ziade.tarek at gmail.com>:
> [l.strip() as stripped for l in text.split('\n') if stripped != '']
Two linkes are better than one:
stripped = [l.strip() for l in text.split('\n')]
[l for l in stripped if l != '']
You are performing two different operations on the list after all. And
more readable.
--
mvh Björn
More information about the Python-ideas
mailing list