title: Assigning string with boolean expression
body: <p>I am trying to understand this code from someone else's project. If you want the context it's here: <a href="https://github.com/newsapps/beeswithmachineguns/blob/master/beeswithmachineguns/bees.py#L501" rel="nofollow">https://github.com/newsapps/beeswithmachineguns/blob/master/beeswithmachineguns/bees.py#L501</a></p>
  
  <p><code>IS_PY2</code> is just a boolean variable, <code>True</code> if the Python major version is 2.
  I know that a non-empty string is <code>True</code>, but for some reason I don't understand <code>openmode</code> is assigned either <code>'w'</code> or <code>'wt'</code> rather than <code>True</code> or <code>False</code>.</p>
  
  <pre><code>openmode = IS_PY2 and 'w' or 'wt'
  openkwargs = IS_PY2 and {} or {'encoding': 'utf-8', 'newline': ''}
  </code></pre>
  
  <p>Could someone explain the result?</p>