ClassName.attribute vs self.__class__.attribute

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Jun 6 10:35:24 EDT 2008


Hrvoje Niksic a écrit :
> "bruno.desthuilliers at gmail.com" <bruno.desthuilliers at gmail.com>
> writes:
> 
>> On 5 juin, 17:40, Gabriel Rossetti <gabriel.rosse... at arimaz.com>
>> wrote:
>>> Hello everyone,
>>>
>>> I had read somewhere that it is preferred to use
>>> self.__class__.attribute over ClassName.attribute to access class (aka
>>> static) attributes.
>> It's even prefered to use self.attribute,
> 
> I was going to write exactly that, but it occurred to me that he might
> want to be *assigning* to self.__class__.attribute (or
> HisClass.attribute) from his methods, in which case self.attribute
> would be quite different.

ACK.



More information about the Python-list mailing list