title: Why should functions always return the same type?
body: <p>I read somewhere that functions should always return only one type
  so the following code is considered as bad code:</p>
  
  <pre><code>def x(foo):
   if 'bar' in foo:
    return (foo, 'bar')
   return None
  </code></pre>
  
  <p>I guess the better solution would be</p>
  
  <pre><code>def x(foo):
   if 'bar' in foo:
    return (foo, 'bar')
   return ()
  </code></pre>
  
  <p>Wouldn't it be cheaper memory wise to return a None then to create a new empty tuple or is this time difference too small to notice even in larger projects?</p>