Author terry.reedy
Recipients docs@python, terry.reedy
Date 2013-07-16.23:39:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1374017954.45.0.193690883208.issue18478@psf.upfronthosting.co.za>
In-reply-to
Content
http://docs.python.org/3/reference/executionmodel.html#naming-and-binding
says "The following are blocks: ... a class definition." and 

"If a name binding operation occurs anywhere within a code block, all uses of the name within the block are treated as references to the current block. This can lead to errors when a name is used within a block before it is bound. ..." 

This is definitely true for functions, but not for classes:

foo = 'bar'
class C:
    foo = foo

print(C().foo)
#
bar

This is the same for 3.3 and 2.7 with and without '(object)' added. Unless the code is considered to be buggy (probably since forever), the doc should be modified to change 'code block' to 'function code block' or maybe 'module or function code block'. (At near as I can think, the statement is true for modules, but only because globals() == locals(), so that part of the issue does not arise.)
History
Date User Action Args
2013-07-16 23:39:14terry.reedysetrecipients: + terry.reedy, docs@python
2013-07-16 23:39:14terry.reedysetmessageid: <1374017954.45.0.193690883208.issue18478@psf.upfronthosting.co.za>
2013-07-16 23:39:14terry.reedylinkissue18478 messages
2013-07-16 23:39:14terry.reedycreate