Re: For loop extended syntax

2005-03-21 Thread Ron
On Sun, 20 Mar 2005 13:16:37 -0500, George Sakkis [EMAIL PROTECTED] 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

Re: For loop extended syntax

2005-03-21 Thread Jeff Shannon
George Sakkis wrote: A generalization of the 'for .. in' syntax that would handle extra arguments the same way as functions would be: for (x,y,z=0,*rest) in (1,2,3), (3,4), (5,6,7,8): print x, y, z, rest I'd love to see this in python one day; it is pretty obvious what it would do for

Re: For loop extended syntax

2005-03-21 Thread Terry Reedy
George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] A generalization of the 'for .. in' syntax that would handle extra arguments the same way as functions would be: for (x,y,z=0,*rest) in (1,2,3), (3,4), (5,6,7,8): print x, y, z, rest I'd love to see this in python

Re: For loop extended syntax

2005-03-21 Thread Greg Ewing
Jeff Shannon wrote: Function arguments are *not* (in general) a case of tuple unpacking, on the other hand, so the parallels between function arguments and for loop control-variable tuples are not so straightforward as is being claimed. It seems to me the parallel is close enough that no

Re: For loop extended syntax

2005-03-21 Thread Kay Schluehr
Terry Reedy wrote: Jeff covered the obvious objection that this is a change from assignment sematics to function call semantics. Slightly less obvious is that this will slow down everyone's for loops for the benefit of the very few who would want to do such a thing. If the action of

For loop extended syntax

2005-03-20 Thread George Sakkis
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

Re: For loop extended syntax

2005-03-20 Thread Kay Schluehr
George Sakkis wrote: 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)] Looks very appealing, but what to do with [x*y-z for (x=0,y,z) in (1,2,3), (4,5), (6,7,8)] ? Should it raise

Re: For loop extended syntax

2005-03-20 Thread Matteo Dell'Amico
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

Re: For loop extended syntax

2005-03-20 Thread George Sakkis
Kay Schluehr [EMAIL PROTECTED] wrote: George Sakkis wrote: 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)] Looks very appealing, but what to do with [x*y-z for (x=0,y,z)

Re: For loop extended syntax

2005-03-20 Thread George Sakkis
Matteo Dell'Amico [EMAIL PROTECTED] wrote: 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

Re: For loop extended syntax

2005-03-20 Thread Heiko Wundram
On Sunday 20 March 2005 20:47, George Sakkis wrote: Not always. Say for example that you're doing some 2D geometry stuff, and later you have to extend it to 3D. In this case you may have to deal with both 2D and 3D objects, and map the former to the latter when necessary. But this rather

Re: For loop extended syntax

2005-03-20 Thread Heiko Wundram
Am Sonntag, 20. März 2005 22:22 schrieb George Sakkis: Once more, the 2D/3D example was just that, an example; my point was not to find a specific solution to a specific problem. And my point being: it's simple enough to give a general recipe (which my example was) without extending Python's

Re: For loop extended syntax

2005-03-20 Thread George Sakkis
Heiko Wundram [EMAIL PROTECTED] wrote: Am Sonntag, 20. März 2005 22:22 schrieb George Sakkis: Once more, the 2D/3D example was just that, an example; my point was not to find a specific solution to a specific problem. And my point being: it's simple enough to give a general recipe (which

Re: For loop extended syntax

2005-03-20 Thread Kay Schluehr
George Sakkis wrote: Looks very appealing, but what to do with [x*y-z for (x=0,y,z) in (1,2,3), (4,5), (6,7,8)] ? Should it raise an exception due to a pattern mismatch? I didn't have in mind to generalize the syntax even more than the respective for function signatures, therefore