x[i] as loop variable

Erik Max Francis max at alcyone.com
Thu Oct 23 21:19:56 EDT 2003


Just wrote:

> But isn't the feature a neccesity to make this work:
> 
>    for a, b in zip(seqA, seqB):
>      ...
> 
> ?

I would guess that's _why_ the "feature" is there, but you can certainly
have one without the other.  To use the EmPy control markup example
again (which is, as I mentioned in another post, intended to mimic the
native Python control structures as closely as is reasonably possible),
I support tuple iteration variables (e.g., @[for x, y in seq]) -- even
hierarchically -- but not the more generalized lvalues (@[for a[i] in
seq] or @[for a.x in seq] are errors).

I would submit that in Python, the latter examples came along as excess
baggage for the purpose for supporting tuple variables (which is indeed
a very useful feature, and thus is supported in EmPy).  I can't imagine
anyone actually using such things deliberately except to be difficult.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Pick the roses from the thorns / Wash with waters of the storms
\__/  Chante Moore




More information about the Python-list mailing list