passing parameters to generators ?
Joal Heagney
s713221 at student.gu.edu.au
Mon Nov 5 04:48:29 EST 2001
Emile van Sebille wrote:
> This came up earlier this week. Here's my response to the earlier question:
>
> 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?
Yow! Emile, how on earth did you discover this, or should I read the PEP
a little more thoroughly?
--
Joal Heagney is: _____ _____
/\ _ __ __ _ | | _ ___ |
/__\|\ || ||__ |\ || |___|/_\|___] |
/ \ \_||__ ||___| \_|! | | \ \ !
More information about the Python-list
mailing list