This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients arigo, terry.reedy
Date 2013-12-23.21:34:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387834479.2.0.238432963056.issue19979@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-12-23 21:34:39terry.reedysetrecipients: + terry.reedy, arigo
2013-12-23 21:34:39terry.reedysetmessageid: <1387834479.2.0.238432963056.issue19979@psf.upfronthosting.co.za>
2013-12-23 21:34:39terry.reedylinkissue19979 messages
2013-12-23 21:34:38terry.reedycreate