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 better is:
spaces = 'spaces' in form and form.getvalue('spaces') == 1

Then you go looking at "form": form.getvalue behaves just like
dict.get, and returns a non-None object (a str object). So the guard
clause can be retired; the ingloriously superobfuscatory original can
be compressed LEGIBLY into
   spaces = form.getvalue('spaces') == "1"


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to