title: Python idiom for applying a function only when value is not None
body: <p>A function is receiving a number of values that are all strings but need to be parsed in various ways, e.g.</p>
  
  <pre><code>vote_count = int(input_1)
  score = float(input_2)
  person = Person(input_3)
  </code></pre>
  
  <p>This is all fine except the inputs can also be <code>None</code> and in this case, instead of parsing the values I would like to end up with <code>None</code> assigned to the left hand side. This can be done with</p>
  
  <pre><code>vote_count = int(input_1) if input_1 is not None else None
  ...
  </code></pre>
  
  <p>but this seems much less readable especially with many repeated lines like this one. I'm considering defining a function that simplifies this, something like</p>
  
  <pre><code>def whendefined(func, value):
      return func(value) if value is not None else None
  </code></pre>
  
  <p>which could be used like</p>
  
  <pre><code>vote_count = whendefined(int, input_1)
  ...
  </code></pre>
  
  <p>My question is, is there a common idiom for this? Possibly using built-in Python functions? Even if not, is there a commonly used name for a function like this?</p>