extending yield's functionality

Emile van Sebille emile at fenx.com
Fri Nov 2 16:53:05 CET 2001


"Eyal Lotem" <eyal at hyperroll.com> wrote in message
news:3be2b616 at news.bezeqint.net...
> I was excited to find out about the new yield functionality, of generator
> functions, that will be formally in 2.3
>
> I wanted to ask if its possible to have yield receive some more
information
> from the caller, between the yield stages.
>

You can share mutable objects to pass in information:

def gf(args):
    while 1:
        yield args[0]*args[1]

a = [2,3]
g = gf(a)
print g.next()
a[1]=4
print g.next()

Is this what you're looking for?

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list