[Python-Dev] zip() and list-comprehension with commas
Wed, 12 Jul 2000 04:44:07 -0500
Ka-Ping Yee wrote:
> As for the SyntaxError, i think it's a good idea because the
> example could be ambiguous. You would have to either say
> [(x, y), for x in list1, if x > 1, for y in list2, if y > 2]
> [x] + [y, for x in list1, if x > 1, for y in list2, if y > 2]
The easy way to avoid the ambiguity is to dump the comma and use colons
as Guido intended.
[for x in list1:
if x > 1:
for y in list2:
if y > 2:
Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it.