title: Compressing `x if x else y` statement in Python
body: <p>I'm quite acquainted with Python's ternary operator approach:</p>
  
  <pre><code>value = foo if something else bar
  </code></pre>
  
  <p>My question is very simple: without prior assignments, is there anyway to reference the term being evaluated in (<code>if ...</code>) from one of the return operands (<code>... if</code> or <code>else ...</code>)?</p>
  
  <p>The motivation here is that sometimes I use expressions in <code>if ...</code> that are exactly what I'd like to have as result in the ternary operation; happens though that, for small expressions, there's no problem repeating it, but for a bit longer expressions, it goes somewhat nasty. Take this as an example:</p>
  
  <pre><code>value = info.findNext("b") if info.findNext("b") else "Oompa Loompa"
  </code></pre>