Determine an object is a subclass of another

Felipe Almeida Lessa felipe.lessa at gmail.com
Tue Jan 9 10:44:45 EST 2007


On 9 Jan 2007 07:01:31 -0800, abcd <codecraig at gmail.com> wrote:
> anyways, is there a way to check without having an instance of the
> class?

In [1]: class A:
   ...:     pass
   ...:

In [2]: class B(A):
   ...:     pass
   ...:

In [3]: issubclass(B, A)
Out[3]: True

In [4]: isinstance(B(), B)
Out[4]: True

In [5]: isinstance(B(), A)
Out[5]: True

--
Felipe.



More information about the Python-list mailing list