Why would I use inspect.isclass()?

Nicolas Fleury nid_oizo at yahoo.com_removethe_
Thu Dec 30 03:50:26 EST 2004


it's me wrote:
> Okay, Nick, I didn't know you can pass a "Class" rather then an instance.  I
> have to chew on what your example does.
> 
> But no, I want to pass an instance of a Class.  But how do I know that the
> calling routine *did* pass me a class - pardon me: an instance of a Class?

You have the builtin function isinstance:

class A: pass
a = A()
print isinstance(a, A)  # True

Regards,
Nicolas



More information about the Python-list mailing list