Message206875
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. |
|
Date |
User |
Action |
Args |
2013-12-23 21:34:39 | terry.reedy | set | recipients:
+ terry.reedy, arigo |
2013-12-23 21:34:39 | terry.reedy | set | messageid: <1387834479.2.0.238432963056.issue19979@psf.upfronthosting.co.za> |
2013-12-23 21:34:39 | terry.reedy | link | issue19979 messages |
2013-12-23 21:34:38 | terry.reedy | create | |
|