In python 2.6, I want to do:
f = lambda x: if x==2 print x else raise Exception() f(2) #should print \"2\" f(3) #should throw an exception <
note you can use several else...if statements in your lambda definition:
f = lambda x: 1 if x>0 else 0 if x ==0 else -1