21 Nov
2014
21 Nov
'14
10:09 p.m.
On Sat, Nov 22, 2014 at 3:53 AM, Chris Barker
As you can write a "generator" in the sense above in a class that supports the iterator protocol (and, can, in fact, write an "iterator" with a generator function), then I say that generator functions really are only syntactic sugar -- they are short and sweet and do much of the book keeping for you.
If you want to consider them that way, then sure - but part of the bookkeeping they do for you is the management of the StopIteration exception. That becomes purely an implementation detail. You don't actually use it when you write a generator function. ChrisA