Vedran Čačić added the comment:

I think this is backwards. "Refusing the temptation to guess" in this case can 
mean returning True for is_iterable. After all, we can always have something 
like

    class Deceptive:
        def __iter__(self):
            raise TypeError("I'm not really iterable")

and it's not the business of instancecheck to actually iterate (either via 
__iter__, or __getitem__). Its task is to check whether it has a corresponding 
attribute (not set to None, per the new convention of explicitly disabling 
protocols).

It could be different if the "old __getitem__ iteration" was deprecated, or at 
least scheduled to be deprecated, but as far as I can tell, it isn't. (It 
really should be documented if it were so.)

_At least_, the documentation of 
https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable 
should be more precise in saying (instead of just "See also the definition of 
iterable.") something like "Note that the definition of iterable in the 
glossary is more general than what this method checks, by design / omission / 
backward compatibility / apathy / whatever."

(Ok, the last part might be too much. But it's essential to point out the 
things are different, and whether it's meant to stay that way.)

----------
nosy: +veky

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

Reply via email to