[Python-ideas] Generators are iterators
apalala at gmail.com
Tue Dec 16 04:50:25 CET 2014
On Sun, Dec 14, 2014 at 7:58 PM, Andrew Barnert <
abarnert at yahoo.com.dmarc.invalid> wrote:
> Sure, but the problem is that people have been writing things that come
> "from the generator's internals", and then trying to explain how those
> things "make generators different from iterators" (or "... from explicit
> __next__ methods"). Because of the wording that was being used, people were
> looking for some way in which generators, or the generator type, or
> generator functions, are different from iterators, from other iterator
> types, or whatever, when none of that is at issue; it's the suspended
> generator frame, which doesn't have any parallel in other iterator
> implementations. I was thinking that if we had some term like "generator
> state" to refer to the frame-and-code (or just the frame, because the code
> isn't really necessary), the confusion wouldn't have arisen.
I never was too much into using an exception to signal than an iterator had
finished its job. Either intuition or experience said that it would be a
source of obscure problems.
I'm not proposing a solution. Not even proposing a change. I do propose
that since this thread has been long and going long, we take the
opportunity to consider the base assumptions.
Most newcomers to programming take a while to grok complex control flows,
and what's happening here is too complex even for Python contributors.
I suggest we revisit "import this" for a little while, just in case we made
a mistake along the way.
Sorry for the rambling!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas