Generators and their next() and send() methods
wuwei23 at gmail.com
Mon Nov 17 01:43:58 CET 2008
On Nov 17, 7:36 am, Thomas Mlynarczyk <tho... at mlynarczyk-webdesign.de>
> Still, I would like to know why it was decided to
> introduce a send() method instead of allowing an argument for next().
A great place to gain insight into the reasoning behind changes to
Python is the PEPs:
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