[Python-Dev] listcomps vs. for loops
Guido van Rossum
guido at python.org
Tue Oct 21 19:27:28 EDT 2003
> > for x in R:
> > ...
> > print x
>
> For which reason I propose that Python 3.0 have the control name in
> any for expression be "local" to the expression ;)
What expression?
If you're talking about making
x = None
for x in R: pass
print x # last item of R
illegal, forget it. That's too darn useful.
> Hmm - actually this does raise another issue.
>
> >>> x = 1
> >>> y = [1, 2, 3]
> >>> y = [x for x in y]
>
> Using the current semantics:
>
> >>> print x
> 3
>
> Using the new semantics:
>
> >>> print x
> 1
>
> Is this a problem? Are the new semantics going to cause confusion?
No, and no; we already went over this (but I don't blame you for not
reading every msg in this thread :-). It does mean that we have to
start issuing proper deprecation warnings, and maybe we won't be able
to properly fix the LC scope thing before 3.0.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list