Re: Name lookup inside class definition

2008-06-18 Thread WaterWalk
Ah, I see. Thank you all. -- http://mail.python.org/mailman/listinfo/python-list

Re: Name lookup inside class definition

2008-06-18 Thread Bruno Desthuilliers
WaterWalk a écrit : Hello. Consider the following two examples: class Test1(object): att1 = 1 def func(self): print Test1.att1// ok or print type(self).att1 class Test2(object): att1 = 1 att2 = Test2.att1 // NameError: Name Test2 is not defined It seem

Re: Name lookup inside class definition

2008-06-17 Thread Robert Lehmann
On Tue, 17 Jun 2008 23:05:56 -0700, WaterWalk wrote: > 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

Name lookup inside class definition

2008-06-17 Thread WaterWalk
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