R. David Murray added the comment:

This is a specific instance of the general principle that a python variable is 
a 'named' location that holds a pointer to an arbitrary python object.  The 
'name' in this case is the variable name that appears in multiple scopes (which 
is what triggers the creation of the cell object...I have no idea at what point 
in the process it is created).  To create a *new* cell object at closure 
creation time (which is essentially what you are advocating if I understand 
correctly) would, I think, change the semantics of Python's scoping rules.  It 
would mean that the behavior would be different depending on whether or not 
'nonlocal' was specified...if it is nonlocal, the behavior *has* to be the 
current behavior.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21904>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to