title: How to define an empty generator function?
body: <p>A generator function can be defined by putting the <code>yield</code> keyword in the function’s body:</p>
  <pre class="lang-py prettyprint-override"><code>def gen():
      for i in range(10):
          yield i
  </code></pre>
  <p>How to define an empty generator function?</p>
  <p>The following code doesn’t work, since Python cannot know that it is supposed to be a generator function instead of a normal function:</p>
  <pre class="lang-py prettyprint-override"><code>def empty():
      pass
  </code></pre>
  <p>I could do something like this:</p>
  <pre class="lang-py prettyprint-override"><code>def empty():
      if False:
          yield
  </code></pre>
  <p>But that would be very ugly. Is there a nicer way?</p>