[Python-Dev] PEP 380 (yield from a subgenerator) comments

P.J. Eby pje at telecommunity.com
Thu Mar 26 18:12:02 CET 2009


At 08:43 PM 3/26/2009 +1200, Greg Ewing wrote:
>Trying to think of a better usage example that
>combines send() with returning values, I've realized
>that part of the problem is that I don't actually
>know of any realistic uses for send() in the first
>place.
>
>Can anyone point me to any? Maybe it will help
>to inspire a better example.

Er, well, I don't know what anybody *else* wanted them for, but I 
wanted them to implement improved trampoline functions, vs. earlier 
Python versions.  ;-)

The trampoline example I gave uses send() in order to pass the return 
values from one generator back into another.  Of course, the task 
object also has a send(), so if you do find another use case for 
send() in a co-operative context, it should be equally doable with 
the trampoline.



More information about the Python-Dev mailing list