title: Nesting the ternary operator in Python
body: <p>In the Zen of Python, Tim Peters states that <code>Flat is better than nested.</code>. If I have understood that correctly, then in Python, this:</p>
  
  <pre><code>&lt;statement-1&gt; if &lt;condition&gt; else &lt;statement-2&gt;
  </code></pre>
  
  <p>is generally preferred over this:</p>
  
  <pre><code>if &lt;condition&gt;:
      &lt;statement-1&gt;
  else:
      &lt;statement-2&gt;
  </code></pre>
  
  <p>However, in other languages, I have been told not to nest the ternary operator, and the instead use the traditional <code>if...else</code>. My question, then, is should I use this:</p>
  
  <pre><code>(&lt;statement-1&gt; if &lt;condition-1&gt; else &lt;statement-2&gt;) if &lt;condition-2&gt; else &lt;statement-3&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>if &lt;condition-2&gt;:
      if &lt;condition-1&gt;:
          &lt;statement-1&gt;
      else:
          &lt;statement-2&gt;
  else:
      &lt;statement-3&gt;
  </code></pre>
  
  <p>? Particularly if the statements and conditions are long, and the first line would need splitting?</p>