Chris Angelico <ros...@gmail.com> wrote:

> For what you're doing, there's a little complexity. If I understand,
> you want send() to be like an ungetc call... you could do that like
> this:
> 
> 
> def ints():
>    i=0
>    while True:
>        sent=(yield i)
>        if sent is not None:
>           yield None  # This becomes the return value from gen.send()
>           yield sent  # This is the next value yielded
>        i += 1

I think this will serve my purposes.

Thanks everyone for broadening my understanding of generators.

Victor.
-- 
Victor Eijkhout -- eijkhout at tacc utexas edu
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to