What is the "sequence"? ([issue16728] collections.abc.Sequence shoud provide __subclasshook__
![](https://secure.gravatar.com/avatar/351a10f392414345ed67a05e986dc4dd.jpg?s=120&d=mm&r=g)
I've report http://bugs.python.org/issue16728 , but I am confused about what is the sequence now. Glossary defines sequence as iteratable having __getitem__ and __len__. Objects doesn't have __iter__ is iterable when it having __getitem__. http://docs.python.org/3/reference/datamodel.html says:
Sequences also support slicing: a[i:j] selects all items with index *k*such that *i* <= *k* < *j*. When used as an expression, a slice is a sequence of the same type. This implies that the index set is renumbered so that it starts at 0.
But I think this sentence explains about standard types and not definition of sequence. http://docs.python.org/3/library/collections.abc.html says:
This module provides *abstract base classes*<http://docs.python.org/3/glossary.html#term-abstract-base-class>that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whether it is a mapping.
And collections.abc.Sequence requires "index()" and "count()". What is the requirement for calling something is "sequence"? Off Topc: Sequence.__iter__ uses __len__ and __getitem__ but default iterator uses only __getitem__. This difference is ugly. -- INADA Naoki <songofacandy@gmail.com>
participants (1)
-
INADA Naoki