title: Is there a way to perform "if" in python's lambda?
body: <p>In <strong>Python 2.6</strong>, I want to do:</p>
  <pre><code>f = lambda x: if x==2 print x else raise Exception()
  f(2) #should print &quot;2&quot;
  f(3) #should throw an exception
  </code></pre>
  <p>This clearly isn't the syntax. Is it possible to perform an <code>if</code> in <code>lambda</code> and if so how to do it?</p>