[Python-ideas] Generators are iterators
abarnert at yahoo.com
Sat Dec 13 09:23:03 CET 2014
On Dec 12, 2014, at 17:32, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 12/12/2014 05:22 PM, Andrew Barnert wrote:
>> On Dec 12, 2014, at 16:40, Chris Barker wrote:
>>> this issue here is that inteh PEP, and in this list, it seems "iterator" was used to describe classes with __init__
>>> and __next__ methods, AS APPOSED to the things returned from functions with a yield in them...
>> But the thing returned by a function without yield in it is an instance of the built-in class generator, which is a
>> subtype of Iterator.
> Um, what?
Sorry, autocorrect typo. The thing returned by a function *with a* (not *without*) yield in it is a generator. And generator is a class with __iter__ and __next__.
Of course an individual generator *instance* isn't such a type, but that's no different from the fact that 2 isn't a number type.
More information about the Python-ideas