classmethod & staticmethod

Alex Popescu nospam.themindstorm at
Tue Jul 24 23:35:58 CEST 2007

Neil Cerutti <horpner at> wrote in
news:slrnfaccgl.1gk.horpner at 

> On 2007-07-24, Alex Popescu <nospam.themindstorm at> wrote:
>> Bruno Desthuilliers <bruno.42.desthuilliers at>
>> wrote in news:46a5b2ad$0$18903$426a74cc at
> [snip...]
>> class MyClass(object):
>>   class_list = ['a', 'b']
>>   def instance_method(self):
>>     print "instance_method with class list %s" % class_list
> There's no implicit self or class for Python identifiers.
> The name class_list must be quailified: self.class_list or
> MyClass.class_list.

After more investigation I have figured this out by myself, but thanks for 
the details.
Now I am wondering if in the above case there is a prefered way:
MyClass.class_list or self.__class__.class_list? (IMO the 2nd is more safe 
in terms of refactorings).

.w( the_mindstorm )p.

More information about the Python-list mailing list