[EMAIL PROTECTED] wrote: > I've done this in Scheme, but I'm not sure I can in Python. > > I want the equivalent of this: > > if a == "yes": > answer = "go ahead" > else: > answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") > > > is there such a form in Python? I tried playing around with lambda > expressions, but I couldn't quite get it to work right.
There will be, in Python 2.5 (final release scheduled for August 2006): >>> answer = "go ahead" if a=="yes" else "stop" See: http://mail.python.org/pipermail/python-dev/2005-September/056846.html http://www.python.org/doc/peps/pep-0308/ --Ben -- http://mail.python.org/mailman/listinfo/python-list