22 Dec
2012
22 Dec
'12
1:03 a.m.
On Fri, Dec 21, 2012 at 2:26 PM, Jonathan Slenders
As far as I understand, "yield from" will always work, because a Future object can act like an iterator, and you can delegate your own generator to this iterator at the place of "yield from". "yield" only works if the parameter behind yield is already a Future object. Right Guido?
Correct! Sounds like you got it now. That's the magic of yield from..
In case of sleep, sleep could be implemented to return a Future object.
It does; in tulip/futures.py: def sleep(when, result=None): future = Future() future._event_loop.call_later(when, future.set_result, result) return future -- --Guido van Rossum (python.org/~guido)