Nov-27-2018, 07:13 PM
No, this is the solution, not the example code for error.
The example code for error is this one:
as explained in the docs, you can test for what is returned. but there is alternative - if instead you use
you can also use
The example code for error is this one:
user = form.getvalue("user").upper()now, if
form.getvalue("user")
returns list and you call upper() on it you will get an error.as explained in the docs, you can test for what is returned. but there is alternative - if instead you use
user = form.getfirst("user", "").upper()it will return just the first element (single string) or "" and upper() will not raise exception
you can also use
form.getlist()
in which case you will always get a list. In any case the code is more compact and clean compared to the one if you check what is returned.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs