[issue16728] collections.abc.Sequence shoud provide __subclasshook__

2012-12-19 Thread INADA Naoki

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 rep...@bugs.python.org
http://bugs.python.org/issue16728
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16728] collections.abc.Sequence shoud provide __subclasshook__

2012-12-19 Thread INADA Naoki

INADA Naoki added the comment:

In Python 3.3:

In [33]: issubclass(Foo, collections.abc.Sequence)
Out[33]: False

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16728
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16728] collections.abc.Sequence shoud provide __subclasshook__

2012-12-19 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Careful, though: dict also provides these methods, but I would not consider it 
a Sequence.

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16728
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16728] collections.abc.Sequence shoud provide __subclasshook__

2012-12-19 Thread Michele OrrĂ¹

Changes by Michele OrrĂ¹ maker...@gmail.com:


--
nosy: +maker

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16728
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16728] collections.abc.Sequence shoud provide __subclasshook__

2012-12-19 Thread INADA Naoki

INADA Naoki added the comment:

I think PySequence_Check() has same problem.

OTOH, mapping definition says:

 A container object that supports arbitrary key lookups and implements the 
 methods specified in the Mapping or MutableMapping abstract base classes.
- http://docs.python.org/3.3/glossary.html#term-mapping

So the mapping should implement all methods defined in collections.abc.Mapping.

If the sequence should implement all methods defined in 
collections.abc.Sequence, it's a documentation bug.

Is there a common view about what is the sequence?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16728
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com