Chris Angelico wrote:
On Thu, Dec 13, 2018 at 3:07 PM Chris Barker - NOAA Federal via
Python-ideas <python-ideas@python.org> wrote:

 obj is iter(obj)

Is that a hard and fast rule?
Yes, it is.

https://docs.python.org/3/library/stdtypes.html#iterator-types

The docs aren't very clear on this point. They claim this is necessary
so that the iterator can be used in a for-loop, but that's obviously
not strictly true, since a proxy object could also be used.

They also make no mention about whether one should be able to rely
on this as a definitive test of iterator-ness.

In any case, I don't claim that my MapView implements the full
iterator protocol, only enough of it to pass for an iterator in
most likely scenarios that assume one.

--
Greg
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to