For loop extended syntax

George Sakkis gsakkis at rutgers.edu
Sun Mar 20 13:16:37 EST 2005


I'm sure there must have been a past thread about this topic but I don't know how to find it: How
about extending the "for <X> in" syntax so that X can include default arguments ? This would be very
useful for list/generator comprehensions, for example being able to write something like:

[x*y-z for (x,y,z=0) in (1,2,3), (4,5), (6,7,8)]

instead of the less elegant explicit loop version that has to check for the length of each sequence.
What do you think ?

George





More information about the Python-list mailing list