wrapping yield ?

Terry Reedy tjreedy at udel.edu
Thu Sep 12 18:45:17 CEST 2002


"Michael Sparks" <Michael.Sparks at rd.bbc.co.uk> wrote in message
news:alqehl$9qv$1 at nntp0.reith.bbc.co.uk...
> Hi,
>
> I'd like to be able to wrap "yield"  in a function - is that
> possible, and if not (my eading of stuff  I've seen so far
> says not) are there any plans to make it possible?
>
> Whilst it may seem odd, I'd like to be able to do this:
>
> def my_generator(arg):
>     dostuff....
>     while(1):
>        waitForSomethingCheckingPeriodically()
>        processit

You have to put in a yield x *somewhere* in order to yield anything to
the caller.
Hard to see why this is a problem.  Something like

x = wait....
yield process(x)

TJR

You are





More information about the Python-list mailing list