
Aug. 28, 2008
4:20 p.m.
Marcin 'Qrczak' Kowalczyk schrieb:
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.
so maybe? [stripped for l in text.split('\n') if stripped != '' let stripped = l.strip()] but this would introduce a new keyword.