Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libcgi.tex @ 32286:882cf11372a3 2.3
[Bug #953177] Mention .getlist(); text from Paul Moore
| author | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Sun, 06 Jun 2004 23:29:05 +0000 |
| parents | a15115290e13 |
| children | 70b1504e17ff |
line wrap: on
line diff
--- a/Doc/lib/libcgi.tex Sun Jun 06 17:41:41 2004 +0000 +++ b/Doc/lib/libcgi.tex Sun Jun 06 23:29:05 2004 +0000 @@ -135,19 +135,14 @@ \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
