[docs] [issue23864] issubclass without registration only works for "one-trick pony" collections ABCs.

Martijn Pieters report at bugs.python.org
Sat Apr 4 13:04:53 CEST 2015


Martijn Pieters added the comment:

I should have added the mixin methods for the Sequence implementation; the more complete demonstration is:

>>> from collections.abc import Sequence, Container, Sized
>>> class MySequence(object):
...     def __contains__(self, item): pass
...     def __len__(self): pass
...     def __iter__(self): pass
...     def __getitem__(self, index): pass
...     def __len__(self): pass
...     def __reversed__(self): pass
...     def index(self, item): pass
...     def count(self, item): pass
... 
>>> issubclass(MySequence, Container)
True
>>> issubclass(MySequence, Sized)
True
>>> issubclass(MySequence, Sequence)
False

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23864>
_______________________________________


More information about the docs mailing list