mirror of
https://github.com/python/cpython.git
synced 2025-11-09 22:16:39 +00:00
Be more consistent, both internally and with recommended practice.
This closes SF bug #547953.
This commit is contained in:
parent
38f71973e5
commit
a7bb2b9b30
1 changed files with 2 additions and 4 deletions
|
|
@ -135,16 +135,14 @@ instance but a list of such instances. Similarly, in this situation,
|
||||||
\samp{form.getvalue(\var{key})} would return a list of strings.
|
\samp{form.getvalue(\var{key})} would return a list of strings.
|
||||||
If you expect this possibility
|
If you expect this possibility
|
||||||
(when your HTML form contains multiple fields with the same name), use
|
(when your HTML form contains multiple fields with the same name), use
|
||||||
the \function{type()} built-in function to determine whether you
|
the \function{isinstance()} built-in function to determine whether you
|
||||||
have a single instance or a list of instances. For example, this
|
have a single instance or a list of instances. For example, this
|
||||||
code concatenates any number of username fields, separated by
|
code concatenates any number of username fields, separated by
|
||||||
commas:
|
commas:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
from types import ListType
|
|
||||||
|
|
||||||
value = form.getvalue("username", "")
|
value = form.getvalue("username", "")
|
||||||
if isinstance(value, ListType):
|
if isinstance(value, list):
|
||||||
# Multiple username fields specified
|
# Multiple username fields specified
|
||||||
usernames = ",".join(value)
|
usernames = ",".join(value)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue