Multiple conditional expression

Grant Edwards grante at visi.com
Thu Feb 26 22:26:09 EST 2009


On 2009-02-27, Anjanesh Lekshminarayanan <mail at anjanesh.net> wrote:

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

   if form.has_key('spaces'):
      spaces = form.getvalue('spaces') == 1
   else:
      spaces = False

However, my code is not acheiving entirely the same thing as
your example code.  The object 'spaces' ends up with the same
value, but my code fails to acheive the other presumed
objective: confusing the reader.
   
-- 
Grant




More information about the Python-list mailing list