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 

    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 

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 
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 <>
Python-bugs-list mailing list

Reply via email to