diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2004-06-06 23:29:05 +0000 |
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2004-06-06 23:29:05 +0000 |
| commit | 67c5b5edf4867ba867c7d4592c72647b9e32a35a (patch) | |
| tree | e1280c0b7ff1c5fdbd1fd1f20fcf0d2b4998d06e | |
| parent | e08a8503da6e452e2e66b5672f9987bdff46d6a6 (diff) | |
| download | cpython-git-67c5b5edf4867ba867c7d4592c72647b9e32a35a.tar.gz | |
[Bug #953177] Mention .getlist(); text from Paul Moore
| -rw-r--r-- | Doc/lib/libcgi.tex | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex index a14717ac88..3cb07b2da3 100644 --- a/Doc/lib/libcgi.tex +++ b/Doc/lib/libcgi.tex @@ -135,19 +135,14 @@ instance but a list of such instances. Similarly, in this situation, \samp{form.getvalue(\var{key})} would return a list of strings. If you expect this possibility (when your HTML form contains multiple fields with the same name), use -the \function{isinstance()} built-in function to determine whether you -have a single instance or a list of instances. For example, this +the \function{getlist()} function, which always returns a list of values (so that you +do not need to special-case the single item case). For example, this code concatenates any number of username fields, separated by commas: \begin{verbatim} -value = form.getvalue("username", "") -if isinstance(value, list): - # Multiple username fields specified - usernames = ",".join(value) -else: - # Single or no username field specified - usernames = value +value = form.getlist("username") +usernames = ",".join(value) \end{verbatim} If a field represents an uploaded file, accessing the value via the |
