ClassName.attribute vs self.__class__.attribute
bruno.42.desthuilliers at websiteburo.invalid
Thu Jun 12 11:17:49 CEST 2008
Mike Orr a écrit :
> 'self' has a .__class__ attribute because it's an
> instance, but MyClass and Superclass do not because they're already
Not true for new-style classes:
>>> class Toto(object): pass
> I sometimes wish classes
> had a .__class__ attribute that's the class itself,
newstyle classes do have a class attribute, that refers to the metaclass.
> but I can see how
> that would cause its own confusion (and recursion).
FWIW, metaclasses do have a class attribute that refers to itself !-)
More information about the Python-list