On Mon, Mar 16, 2015 at 9:09 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: > Ian Kelly <ian.g.ke...@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
My (limited) experience with asyncio is that it also makes this a bit worse. I write a function intended to be a coroutine invoked from coroutines using "yield from", and then I realize that it's not a coroutine because it never uses "yield from" itself. Or inversely I write a normal utility function that is called from coroutines, then later add a "yield from" to it, and now I have to go back and revise every place where it's called to make those use "yield from" as well. -- https://mail.python.org/mailman/listinfo/python-list