Multiple conditional expression

Steve Holden steve at holdenweb.com
Thu Feb 26 22:14:50 EST 2009


Anjanesh Lekshminarayanan wrote:
> How do I achieve something like this using python ?
> spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True
> : False : False)
> 
> spaces = True if form.getvalue('spaces') == 1 if
> form.has_key('spaces') else False else False

If you've got any sense at all, you don't. Write the logic so it makes
some sense to the casual reader. You will be that casual reader in a few
months.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list