title: How to write Python generator function that never yields anything
body: <p>I want to write a Python generator function that never actually yields anything.  Basically it's a "do-nothing" drop-in that can be used by other code which expects to call a generator (but doesn't always need results from it).  So far I have this:</p>
  
  <pre><code>def empty_generator():
      # ... do some stuff, but don't yield anything
      if False:
          yield
  </code></pre>
  
  <p>Now, this works OK, but I'm wondering if there's a more expressive way to say the same thing, that is, declare a function to be a generator even if it never yields any value.  The trick I've employed above is to show Python a yield statement inside my function, even though it is unreachable.</p>