title: if statement list-comprehension style
body: <p>I'm wondering if there is a pythonic way of achieving an if-statement in &quot;list-comprehension style&quot;. If it exists, the solution is probably an easy one, but I have no clue where to look this up (or how this is called).</p>
  <pre class="lang-py prettyprint-override"><code>mylist= [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]
  
  x = &quot;bar&quot;
  
  mc = MyClass(param1 =foo, param2=bar, is_expected=[x if x in mylist]
  
  </code></pre>
  <p>Depending on the value <code>x</code> holds, the value of the parameter <code>is_expected</code> should been set (<code>True</code> if it's in the list, otherwiese <code>False</code>) and passed to the constructor.</p>