title: Don't call function if None Value returned
body: <p>suppose you have a function that can return some object or None:</p>
  
  <pre><code>def foobar(arg):
     if arg == 'foo':
         return None
     else:
         return 'bar'
  </code></pre>
  
  <p>Now you call this method and you want to do something with the object, for this example i get a <code>str</code>, so i may want to call the <code>upper()</code> function.
  There are now two cases that can happen, where the second one will fail, because None has no method <code>upper()</code></p>
  
  <pre><code>foobar('sdfsdgf').upper()
  foobar('foo').upper() 
  </code></pre>
  
  <p>of course this is now easy to fix:</p>
  
  <pre><code>tmp = foobar('foo')
  if tmp is not None:
      tmp.upper()
  # or
  try:
      foobar('foo').upper()
  except ArgumentError:
      pass
  # or
  caller = lambda x: x.upper() if type(x) is str else None
  caller(foobar('foo'))
  </code></pre>
  
  <p>but the exception handling is maybe not specfic enough and it can happen that i catch an exception that could be important (= debugging gets harder), while the first method is good but can result in larger code and the third option looks quite nice but you have to do it for all possible functions so method one is probably the best.</p>
  
  <p>I wonder if there is any syntactic sugar that handle this problem nicely?</p>