multiple parameters in if statement
John Machin
sjmachin at lexicon.net
Sun Apr 16 03:17:17 EDT 2006
On 16/04/2006 1:43 PM, John Zenger wrote:
>
> The other thing I'd recommend is stick that long list of fields in a
> list, and then do operations on that list:
>
> fields = ['delete_id', 'delete_date', 'delete_purchasetype',
> 'delete_price', 'delete_comment']
>
> then to see if all those fields are empty:
>
> everything = ""
> for field in fields:
> everything += form.get(field,"")
Or everything = "".join(form.get(field, "") for field in fields)
Somewhat labour-intensive. It appears from the OP's description that no
other entries can exist in the dictionary. If this is so, then:
everything = "".join(form.values())
but what the user sees on screen isn't necessarily what you get, so:
everything = "".join(form.values()).strip()
> if everything == "":
> print "Absolutely nothing entered!"
>
More information about the Python-list
mailing list