I try to define a generator function mycount() that can be reset with the generator function send(0) as in the example below. Everything works fine
In particular, you might find a way to use the consumer decorator described on p. I-131 of David Beazley's "Generator Tricks," to which J. Gwyn provided a link:
def consumer(func):
def start(*args,**kwargs):
c = func(*args,**kwargs)
c.next()
return c
return start
I use something similar in my code.
Note that if v is None is preferred over if v == None.