Casey Hawthorne wrote: > Since there was talk of if-then-else not being allowed in lambda > expressions, the following is from "Dive into Python" > > The and-or conditional expression trick from page 41 of "Dive into > Python" > > Wrap the arguments in lists and then take the first element. > >>>> a = "" >>>> b = "second" >>>> (1 and [a] or [b])[0] > ''
# python 2.5 >>> a, b = "", 0 >>> a if False else b 0 >>> a if True else b '' Time to tear out that page. Really. Peter -- http://mail.python.org/mailman/listinfo/python-list