generator/coroutine terminology
Marko Rauhamaa
marko at pacujo.net
Mon Mar 16 11:09:47 EDT 2015
Ian Kelly <ian.g.kelly at gmail.com>:
> For generators, the descriptive keyword ("yield") could be buried
> *anywhere* in that block. One can glance at a generator function and
> fail to notice that it is a generator function. This is the one that
> really bugs me about reuse of "def", although you are correct that
> this is a case where practicality has won over purity.
I don't think that's all that big of a deal even though I will readily
admit having stumbled on it early on. I removed the last "yield"
statement from a generator expecting it to keep on being a generator.
Thus, you have to do things like:
def nothing():
if False:
yield None
The "pass" and "global" statements make me think it might be more
Pythonic to have separate syntax for the special case:
def nothing():
yield not
Marko
More information about the Python-list
mailing list