31 May
2007
31 May
'07
4:30 a.m.
Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Arnaud Delobelle wrote:
Why not just drop the 'x for' at the start of a 'filter comprehension' (or generator expression)? Thus (3) could be written more simply as:
(3') [x in L if p(x)]
It would be very nice, but could be difficult to parse, because there's no clue you're not looking at a normal list constructor until you get to the 'if'.
Even then it's not terribly clear except that there's a missing 'else' clause for conditionals... y = [x in L if p(x) else None] Will create a list of a single value in Python 2.5 . - Josiah