Re: Multiple conditional expression

2009-03-03 Thread Mel
bearophileh...@lycos.com wrote: Chris Rebert: That seems to just be an overly complicated way of writing: spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1) Better: spaces = bool(('spaces' in form) and form.getvalue('spaces') == 1) Is it still necessary to convert the

Re: Multiple conditional expression

2009-03-03 Thread John Machin
On Mar 4, 10:53 am, Mel mwil...@the-wire.com wrote: bearophileh...@lycos.com wrote: Chris Rebert: That seems to just be an overly complicated way of writing: spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1) Better: spaces = bool(('spaces' in form) and

Re: Multiple conditional expression

2009-03-02 Thread Bruno Desthuilliers
Steve Holden a écrit : Anjanesh Lekshminarayanan wrote: How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True: False :

Re: Multiple conditional expression

2009-03-02 Thread Christian Tismer
On 3/2/09 12:53 AM, Bruno Desthuilliers wrote: Steve Holden a écrit : Anjanesh Lekshminarayanan wrote: How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces')

Re: Multiple conditional expression

2009-03-02 Thread John Machin
On Feb 27, 7:55 pm, bearophileh...@lycos.com wrote: Chris Rebert: That seems to just be an overly complicated way of writing: spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1) Better: spaces = bool(('spaces' in form) and form.getvalue('spaces') == 1) Huh?? Much

Re: Multiple conditional expression

2009-02-27 Thread bearophileHUGS
Chris Rebert: That seems to just be an overly complicated way of writing: spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1) Better: spaces = bool(('spaces' in form) and form.getvalue('spaces') == 1) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple conditional expression

2009-02-27 Thread Steve Holden
Anjanesh Lekshminarayanan wrote: How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True: False : False) is

Multiple conditional expression

2009-02-26 Thread Anjanesh Lekshminarayanan
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 -- Anjanesh Lekshmnarayanan --

Re: Multiple conditional expression

2009-02-26 Thread Steve Holden
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

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 7:11 PM, Anjanesh Lekshminarayanan m...@anjanesh.net 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

Re: Multiple conditional expression

2009-02-26 Thread Grant Edwards
On 2009-02-27, Anjanesh Lekshminarayanan m...@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:

Re: Multiple conditional expression

2009-02-26 Thread Paul Rubin
Chris Rebert c...@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

Re: Multiple conditional expression

2009-02-26 Thread Grant Edwards
On 2009-02-27, Paul Rubin http wrote: But the == 1 comparison will always fail, since getvalue returns a string. How do we know that from the what the OP posted? -- Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple conditional expression

2009-02-26 Thread Anjanesh Lekshminarayanan
How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True: False : False) is complicated in anyway. Its not that hard to read

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:39 PM, Anjanesh Lekshminarayanan m...@anjanesh.net wrote: How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ?