List comprehension...
Greg Ewing
greg.ewing at compaq.com
Mon Dec 13 08:27:40 EST 1999
"Magnus L. Hetland" wrote:
>
> [(i, s) for i in nums and s in strs]
That would be ambiguous, because it could be parsed as
[(i, s) for i in (nums and s in strs)]
It *might* be feasible to use
[(i, s) for i in nums and for s in strs]
If I get a spare moment or two one day I'll try this
and see whether the parser chokes. (Python's parser
is a bit strange - it's hard to predict what it can
handle and what it can't.)
Greg
More information about the Python-list
mailing list