[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

Andrew Barnert report at bugs.python.org
Sat Dec 26 21:37:07 EST 2015


Andrew Barnert added the comment:

> This sounds good. Also, reversed() could then be modified to produce a
better error.

Should `iter` also be modified to produce a better error if `__iter__` is None?

Also, should this be documented? Maybe a sentence in the "Special method names" section of the "Data model" chapter, like this:

> To indicate that some syntax is not supported, set the corresponding special method name to None. For example, if __iter__ is None, the class is not iterable, so iter() will not look for __getitem__.

----------

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


More information about the Python-bugs-list mailing list