wrapping yield ?
Michael.Sparks at rd.bbc.co.uk
Fri Sep 13 12:17:40 CEST 2002
"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
news:Xns92885F082A21Cduncanrcpcouk at 127.0.0.1...
> So something like this should work:
> def my_generator(arg):
> for item in waitForSomethingCheckingPeriodically():
> if item is None:
> yield None
Whereas if I could wrap up yield, I simply have to do:
item = waitForSomethingCheckingPeriodically()
Which if I have lots of this sort of thing going on, results in much
clearer (and hence maintainable) code.
If it can't (putting yield in a function, and not turning the function into
generator) be done, and AFAICT it can't, and this is a suggested work
around - many thanks :-)
More information about the Python-list