how to find out if an object is a class?

Christian Heimes lists at cheimes.de
Fri Aug 8 09:04:56 EDT 2008


szczepiq wrote:
> Pardon me for most likely a dummy question but how do I find out if an
> object is a class?

For God's sake don't reinvent the wheel! The 'inspect' module (part of 
the Python standard library) has a functions isclass(). It does the 
proper tests for new style and old style classes.

import inspect
inspect.isclass(something)

Christian




More information about the Python-list mailing list