isinstance method

Peter Hansen peter at engcorp.com
Tue Mar 16 15:41:02 EST 2004


niurka.perez at cimex.com.cu wrote:

> I need to find out dynamically if an object is instance of a Class but I don't
> know how to use this isinstance buit-in function. I have the object and the name
> of the class, what should I do?

Many classes can have the same name, so you additionally must know which 
module (i.e. have a reference to the module) in which the class was defined.

Then, knowing that a module responds as a dict object, you can retrieve 
an actual reference to the class and carry on as Erik Max Francis showed 
you.

-Peter



More information about the Python-list mailing list