New submission from INADA Naoki:
http://docs.python.org/3.3/glossary.html#term-sequence
__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 <[email protected]>
<http://bugs.python.org/issue16728>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com