Get the class name

Tuomas Vesterinen tuomas.vesterinen at iki.fi
Sun Jun 7 16:41:37 EDT 2009


Kless wrote:
> Is there any way of to get the class name to avoid to have that write
> it?
> 
> ---------------
> class Foo:
>    super(Foo, self)
> ---------------
> 
> 
> * Using Py 2.6.2

 >>> class Foo(object):
...     def cls(self):
...         return self.__class__
...
 >>> Foo().cls()
<class '__main__.Foo'>



More information about the Python-list mailing list