Finding the name of a class

Kirk Strauser kirk at strauser.com
Tue Aug 1 11:22:34 EDT 2006


Given a class:

>>> class foo(object):
>>>     pass

how can I find its name, such as:

>>> b = foo
>>> print something(b)
'foo'

I'm writing a trace() decorator for the sake of practice, and am trying to
print the name of the class that a traced method belongs to.  This seems
like it should be easy, but I think I've been staring at the problem too
long.
-- 
Kirk Strauser



More information about the Python-list mailing list