Andrew Barnert added the comment:

As Guido pointed out on -ideas, hashing already uses the convention of 
`__hash__ is None` to declare a type unhashable, and 
`collections.abc.Hashable.__subclasshook__` already checks for that.

Meanwhile, setting `__iter__` and `__reversed__` to `None` already raises a 
`TypeError` on `iter` and `reversed` (although not with the most helpful 
description).

So, maybe that should be documented as the standard way to unimplement 
`__iter__` and `__reversed__`, and `collections.abc.Iterable` should check that 
the looked-up `__iter__` is not `None` (and presumably typecheckers doing the 
equivalent for both `Iterable` and `Reversible`)?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to