[Python-Dev] Lockstep iteration - eureka!

Greg Ewing greg@cosc.canterbury.ac.nz
Thu, 10 Aug 2000 14:12:08 +1200 (NZST)


Thomas Wouters <thomas@xs4all.net>:

> The only objection I can bring up is that parentheses are almost always
> optional, in Python, and this kind of violates it.

They're optional around tuple constructors, but this is not
a tuple constructor.

The parentheses around function arguments aren't optional
either, and nobody complains about that.

> 'for (x in a, y in b) in z:' *is* valid syntax...

But it's not valid Python:

>>> for (x in a, y in b) in z:
...   print x,y
... 
SyntaxError: can't assign to operator

> It might not be too pretty, but it can be worked around ;)

It wouldn't be any uglier than what's currently done with
the LHS of an assignment, which is parsed as a general
expression and treated specially later on.

There's-more-to-the-Python-syntax-than-what-it-says-in-
the-Grammar-file-ly,

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+