Getting a class name

deelan ggg at zzz.it
Sat Feb 17 15:33:44 EST 2007


Harlin Seritt wrote:
> Hi,
> 
> How does one get the name of a class from within the class code? I
> tried something like this as a guess:
> 
> self.__name__

Get the class first, then inspect its name:

 >>> class Foo(object): pass
...
 >>> f = Foo()
 >>> f.__class__.__name__
'Foo'
 >>>

HTH


-- 
d.



More information about the Python-list mailing list