title: Conditional formatting using pyformat
body: <p>Given some variable</p>
  
  <pre><code>flag = True
  x = "hello"
  y = "world"
  </code></pre>
  
  <p>I would like to print the following string:</p>
  
  <p><code>"hello world"</code> if <code>flag is True</code> or <code>"hello 'world'"</code> if <code>flag is False</code>.
  This could be done using the following statement:</p>
  
  <pre><code>print("{} {}".format(x, y if flag else "'{}'".format(y)))
  </code></pre>
  
  <p>The question is, can such a conditional format be specified directly using pyformat? I.e. is it possible to specify different format strings depending on some variable?</p>
  
  <p>One solution might be to do two formats:</p>
  
  <pre><code>'{{}} {}'.format("{}" if flag else "'{}'").format(x, y)
  </code></pre>
  
  <p>But this makes it very hard to read as you have to escape the not replaced formats in the first string.</p>