title: Is there a Python function that checks if a generator is started?
body: <p>I try to define a generator function <code>mycount()</code> that can be reset with the generator function <code>send(0)</code> as in the example below. Everything works fine, except when I use <code>send(0)</code> on a new generator object that hasn't started yet. In this case it gives a <code>TypeError</code>. Is there any function that checks if the generator has started or do I have to catch the <code>TypeError</code> and create a new generator object with <code>mycount(0)</code> in such case?</p>
  
  <pre><code>def mycount(value):
      while True:
          v = yield value
          if v == None:
              value = value + 1
          else:
              value = v
  
  g = mycount(3)
  print(next(g))    # prints 3
  print(next(g))    # prints 4
  print(g.send(0))  # prints 0
  print(next(g))    # prints 1
  print(next(g))    # prints 2
  
  g2 = mycount(3)
  g2.send(0)
  # TypeError: can't send non-None value to a just-started generator
  </code></pre>