title: Does Python have the Elvis operator?
body: <p>The ternary operator in many languages works like so:</p>
  
  <pre><code>x = f() ? f() : g()
  </code></pre>
  
  <p>Where if <code>f()</code> is truthy then <code>x</code> is assigned the value of <code>f()</code>, otherwise it is assigned the value of <code>g()</code>. However, some languages have a more succinct <a href="https://en.wikipedia.org/wiki/Elvis_operator" rel="noreferrer"><em>elvis</em> operator</a> that is functionally equivalent:</p>
  
  <pre><code>x = f() ?: g()
  </code></pre>
  
  <p>In python, the <em>ternary</em> operator is expressed like so:</p>
  
  <pre><code>x = f() if f() else g()
  </code></pre>
  
  <p>But does python have the more succinct <em>elvis</em> operator?</p>
  
  <p>Maybe something like:</p>
  
  <pre><code>x = f() else g() # Not actually valid python
  </code></pre>