Message83011
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. |
|
Date |
User |
Action |
Args |
2009-03-02 10:37:02 | paul.moore | set | recipients:
+ paul.moore |
2009-03-02 10:37:02 | paul.moore | set | messageid: <1235990222.31.0.178922023306.issue5405@psf.upfronthosting.co.za> |
2009-03-02 10:37:00 | paul.moore | link | issue5405 messages |
2009-03-02 10:36:59 | paul.moore | create | |
|