Turning a callback function into a generator
Kirk McDonald
kirklin.mcdonald at gmail.com
Mon Jul 3 00:18:05 EDT 2006
Let's say I have a function that takes a callback function as a
parameter, and uses it to describe an iteration:
def func(callback):
for i in [1, 2, 3, 4, 5]:
callback(i)
For the sake of argument, assume the iteration is something more
interesting than this which relies on the callback mechanism. The
function is an existing interface, and I cannot change it.
I want to somehow, in some way, provide an iteration interface to this
function. Thoughts?
-Kirk McDonald
More information about the Python-list
mailing list