creating generators from function
simonwittber at gmail.com
Wed Dec 8 15:18:27 CET 2004
> I'm a little confused as to what you're trying to do here. The f()
> function, in particular, doesn't make much sense
I see I am misunderstood. The example was contrived, and it seems, incorrect.
I simulate threads, using generator functions and a scheduler.
My implementation lives here: http://metaplay.com.au/svn/LGT/LGT/nanothreads.py
If the same functions were to run inside a normal thread, they would
need to loop forever, rather than yield None on each iteration. I see
now that replacing return with yield won't work, a yield instruction
needs to be inserted somewhere.
I guess this changes my question to: Can I convert a function
containing an infinite loop, into a generator which will yield on each
More information about the Python-list