[Python-Dev] listcomps vs. for loops

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Tue Oct 21 19:11:44 EDT 2003


> From: Jp Calderone [mailto:exarkun at intarweb.us.avaya.com]
>> Not when x is properly initialized. Anyway, this is no 
> different from the
> problem of:
>> 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 ;)
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?
Tim Delaney


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /