On Wed, Dec 12, 2018 at 08:06:17PM -0800, Chris Barker - NOAA Federal wrote: > >>> and the test for an iterator is: > >>> > >>> obj is iter(obj) > > Is that a hard and fast rule?
Yes, that's the rule for the iterator protocol. Any object can have an __iter__ method which returns anything you want. (It doesn't even have to be iterable, this is Python, and if you want to shoot yourself in the foot, you can.) But to be an iterator, the rule is that obj.__iter__() must return obj itself. Otherwise we say that obj is an iterable, not an iterator. https://docs.python.org/3/library/stdtypes.html#iterator.__iter__ -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/