Name lookup inside class definition
WaterWalk
toolmaster at 163.com
Wed Jun 18 02:05:56 EDT 2008
Hello. Consider the following two examples:
class Test1(object):
att1 = 1
def func(self):
print Test1.att1 // ok
class Test2(object):
att1 = 1
att2 = Test2.att1 // NameError: Name Test2 is not defined
It seems a little strange. Why a class name can be used in a method
while cannot be used in the class block itself? I read the "Python
Reference Manual"(4.1 Naming and binding ), but didn't get a clue.
More information about the Python-list
mailing list