Terry J. Reedy added the comment:
As near as I can tell, "class A: n = n" currently works the same at module and
nested scope, the latter with or without nonlocal n.
>>> class A: n=n
[...]
NameError: name 'n' is not defined
>>> def f():
class A: n=n
>>> f()
[...]
NameError: name 'n' is not defined
>>> def f(n):
class A: n=n
>>> f(2)
[...]
NameError: name 'n' is not defined
Repeat after 'n=1' at module scope and the NameErrors disappear. It appears
that you are asking that the class statement be made to act differently when
nested instead of the same. This would break code that depends on the current
behavior. This would need discussion on python-ideas and pydev lists.
----------
nosy: +terry.reedy
stage: -> test needed
type: -> enhancement
versions: +Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19979>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com