title: Why does this "and-or" ternary expression syntax work?
body: <p>I have recently been learning and working with Python, and came across the following code, which I was told is a common shorthand for a ternary expression in Python:</p>
  
  <pre><code>x = condition and expression1 or expression2
  </code></pre>
  
  <p>Now I'm familiar with the <code>? :</code> operators in C-like languages, and with Python's usual ternary expression <code>x = expression1 if condition else expression2</code>, but this new expression seemed a bit odd to me.</p>
  
  <p>Part of my confusion is that it doesn't seem very readable, i.e. when I read that line it doesn't immediately make it clear what is happening, but the other part is that I don't quite understand why it works.</p>
  
  <p>In summary: <strong>Why does the expression above function the same as a C-like ternary expression?</strong></p>