Testing for is-kind-of relationships (at runtime)

Fredrik Lundh fredrik at effbot.org
Thu Jan 18 18:31:18 EST 2001


Alain Desilets wrote:
> For example, suppose x is an instance of A which is a subclass of B
> which is a subclass of C. I want to be able to ascertain at run time
> that x is a descendant of class C.

assert isinstance(x, C)

Cheers /F





More information about the Python-list mailing list