
Aug. 28, 2008
9:04 a.m.
2008/8/28 Cesare Di Mauro <cesare.dimauro@a-tono.com>:
A solution could be this:
[stripped for l in text.split('\n') with l.strip() as stripped if stripped != '']
so that you can keep both values (l and l.strip()) too.
In Haskell this would be (I translate only the list comprehension structure, leaving expressions in Python syntax): [stripped | l <- text.split('\n'), let stripped = l.strip(), stripped != ''] Python borrowed 2 out of 3 kinds of list comprehension constructs. -- Marcin Kowalczyk qrczak@knm.org.pl http://qrnik.knm.org.pl/~qrczak/