[Python-ideas] The async API of the future: yield-from

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Oct 21 04:46:05 CEST 2012


Guido van Rossum wrote:
> In the PEP 380 world, there will be a new type of mistake possible:
> writing yield instead of yield from. Fortunately the scheduler can
> easily test for this -- if the result of its calling next() is not
> None, the user yielded something.

That will catch some mistakes of that kind, but not all --
it won't catch 'yield foo()' where foo() returns None.

One way to fix that would be to require yielding some
unique sentinel value. If the yields are all hidden inside
primitives called with 'yield from', that could be kept
an implementation detail.

-- 
Greg



More information about the Python-ideas mailing list