runtime type information in python?

Daniel Berlin dan at cgsoftware.com
Wed Aug 23 01:46:06 EDT 2000


On Wed, 23 Aug 2000, Issac Trotts wrote:

> Suppose I execute the following code:
> 
> class C: pass
> class B(C): pass
> b=B();
> 
> How do I find out what kind of object b is?

Easy, it's an instance.

use type(b) to find that out.

> How can I find out whether b is-a C?
isinstance(b,C)

> 
> Thanks,
> Issac
> 
> 
> 
> 





More information about the Python-list mailing list