Author paul.moore
Recipients paul.moore
Date 2009-03-02.10:36:59
SpamBayes Score 0.000182475
Marked as misclassified No
Message-id <1235990222.31.0.178922023306.issue5405@psf.upfronthosting.co.za>
In-reply-to
Content
There is no way to determine the list of classes for which issubclass(C,
x) is true. The MRO of the class is fine for normal inheritance, but for
ABCs it is possible to register classes which don't inherit from the
ABC, so that you have a situation where issubclass (C, MyABC) can be
true without MyABC being in C.__mro__:

>>> import abc
>>> class MyABC(object):
...     __metaclass__ = abc.ABCMeta
...
>>> class C(object):
...     pass
...
>>> MyABC.register(C)
>>> issubclass(C, MyABC)
True
>>> C.__mro__
(<class '__main__.C'>, <type 'object'>)
>>>

This means that ABCs do not play well with the type of introspection
required to implement such features as generic functions - namely
enumeration of the (logical) superclasses of a class.
History
Date User Action Args
2009-03-02 10:37:02paul.mooresetrecipients: + paul.moore
2009-03-02 10:37:02paul.mooresetmessageid: <1235990222.31.0.178922023306.issue5405@psf.upfronthosting.co.za>
2009-03-02 10:37:00paul.moorelinkissue5405 messages
2009-03-02 10:36:59paul.moorecreate