title: Checking if a key exists and its value is not an empty string in a Python dictionary
body: <p>Is there a clear best practice for assigning a variable from a key/value pair in a Python dictionary:</p>
  
  <ul>
  <li>If the key is present</li>
  <li>If the key's value is not an empty string</li>
  </ul>
  
  <p>And otherwise assigning a default value to the variable.</p>
  
  <p>I would like to use <code>dict.get</code>:</p>
  
  <pre><code>my_value = dict.get(key, my_default)
  </code></pre>
  
  <p>But this assigns an empty string to <code>my_value</code> if the key is present and the value is an empty string. Is it better to use the following:</p>
  
  <pre><code>if key in dict and dict[key]:
      my_value = dict[key]
  else:
      my_value = my_default
  </code></pre>
  
  <p>This would make use of the truthfulness of an empty string to ensure only non-empty strings were assigned to <code>my_value</code>.</p>
  
  <p>Is there a better way to perform this check?</p>