For loop extended syntax

Matteo Dell'Amico della at toglimi.linux.it
Sun Mar 20 14:27:32 EST 2005


George Sakkis wrote:
> 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 ?

How did you get the data in that format in the first place? It looks a 
bit strange to me. Wouldn't it be easier to fill in default values when 
you gather data as opposed to when you use it?

-- 
Ciao,
Matteo



More information about the Python-list mailing list