revive a generator
Yingjie Lan
lanyjie at yahoo.com
Fri Oct 21 04:40:54 EDT 2011
----- Original Message -----
> From: Paul Rudin <paul.nospam at rudin.co.uk>
>
> I'm not really sure whether you intend g to yield the original values
> after your "revive" or new values based on the new value of vo. But
> still you can make a class that supports the iterator protocol and does
> whatever you want (but you can't use the generator expression syntax).
>
> If you want something along these lines you should probably read up on
> the .send() part of the generator protocol.
>
> As an aside you shouldn't really write code that uses a global in that
> way.. it'll end up biting you eventually.
>
> Anyway... we can speculate endlessly about non-existent language
> constructs, but I think we've probably done this one to death.
> --
Maybe no new language construct is needed:
just define that x.send() revives a generator.
Yingjie
More information about the Python-list
mailing list