How to examine the inheritance of a class?
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Fri Oct 24 02:11:21 EDT 2008
On Thu, 23 Oct 2008 20:53:03 -0700, John Ladasky wrote:
> On Oct 23, 6:59 pm, "James Mills" <prolo... at shortcircuit.net.au> wrote:
>
>> Developer. NOT User.
>
> For the foreseeable future, this program is for my use only. So the
> developer and the user are one and the same.
>
> And, thank you, __bases__ is what I was looking for. Though Chris Mills
> also pointed out that isinstance() handles the type checking nicely.
issubclass() may be better than directly looking at __bases__.
This may not matter if your only writing for yourself, but beware that
the use of issubclass() and isinstance() will wreck duck-typing and
prevent such things as delegation from working correctly.
--
Steven
More information about the Python-list
mailing list