Hello,

I was playing around a bit with generators using next() and send(). And I was wondering why an extra send() method was introduced instead of simply allowing an argument for next().

Also, I find it a bit counter-intuitive that send(42) not only "sets" the generator to the specified value, but yields the next value at the same time.

As an exercise, I wanted to somehow "modify" a generator so that it would have a next() method accepting an argument, something like

@myway
def gen():
    pass

But I failed to come up with an implementation of the myway() function.

Any comments and/or suggestions?

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to