Generators and their next() and send() methods

alex23 wuwei23 at gmail.com
Sun Nov 16 19:43:58 EST 2008


On Nov 17, 7:36 am, Thomas Mlynarczyk <tho... at mlynarczyk-webdesign.de>
wrote:
> Still, I would like to know why it was decided to
> introduce a send() method instead of allowing an argument for next().

Hey Thomas,

A great place to gain insight into the reasoning behind changes to
Python is the PEPs:

http://www.python.org/dev/peps/pep-0342/

That links to the original proposal to extend the generator behaviour
to include send. I haven't the time right now to read it but if
anything is going to explain the choice, it'll be there.

At a guess, I'd expect a new method was chosen to provide semantic
distinctness with the original behaviour. Or maybe so it wouldn't
break any existing code with decorators such as your's :)




More information about the Python-list mailing list