My (late) beef with Simple Generator syntax (PEP 255)
Terry Reedy
tjreedy at udel.edu
Wed Nov 13 20:17:26 EST 2002
"Cameron Horn" <camhorn at mac.com> wrote in message
news:mailman.1037219902.17042.python-list at python.org...
> If I want to write an empty generator, I write this(?):
> def foo():
> return
> yield "never"
>
> Assuming that having an empty generator is as valid as empty
functions and classes,
> what kind of linguistic cruft is that? I expect better out of
python, dang it.
I challenge the assumption. A generator, by definition, is a
(nonempty) function (and not a separate generator type) that returns
an iterator with __iter__ and next methods.
TJR
More information about the Python-list
mailing list