Multiple conditional expression

Paul Rubin http
Thu Feb 26 22:34:29 EST 2009


Chris Rebert <clp2 at rebertia.com> writes:
> spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1)

 spaces = form.has_key('spaces') and form.getvalue('spaces') == 1

or even (this is about the cgi module, I think)

 spaces = form.getvalue('spaces', None) == 1

But the == 1 comparison will always fail, since getvalue returns a string.



More information about the Python-list mailing list