[New-bugs-announce] [issue16728] collections.abc.Sequence shoud provide __subclasshook__

INADA Naoki report at bugs.python.org
Wed Dec 19 13:14:49 CET 2012

New submission from INADA Naoki:


__getitem__ and __len__ are required for sequence type.
(__iter__ is not required because types having __getitem__ are already iterator.)

.__contains__(), .index() and .count() is not required for sequence.

For example, following class should be sequence.

class Foo:
    def __getitem__(self, index):
        if not isinstance(index, int):
            raise TypeError
        if index >= 3:
            raise IndexError
        return index

    def __len__(self):
        return 3

components: Library (Lib)
messages: 177737
nosy: naoki
priority: normal
severity: normal
status: open
title: collections.abc.Sequence shoud provide __subclasshook__
versions: Python 3.3, Python 3.4, Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list