title: Best idiom to get and set a value in a python dict
body: <p>I use a <code>dict</code> as a short-term cache. I want to get a value from the dictionary, and if the dictionary didn't already have that key, set it, e.g.:</p>
  
  <pre><code>val = cache.get('the-key', calculate_value('the-key'))
  cache['the-key'] = val
  </code></pre>
  
  <p>In the case where <code>'the-key'</code> was already in <code>cache</code>, the second line is not necessary. Is there a better, shorter, more expressive idiom for this?</p>