[Python-ideas] For-loop variable scope: simultaneous possession and ingestion of cake

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 4 04:46:04 CEST 2008

Neil Toronto wrote:

> Python could close over the values rather than a cell. That's *almost 
> always* what people really care about anyway! It'd break almost no code.

No, it would break huge amounts of code. Consider

   def f():

   def g():
     print "Gee"

Would you really like to get a NameError or
UnboundLocalError on g here?


More information about the Python-ideas mailing list