From: Andrew M. Kuchling Date: Sun, 6 Jun 2004 23:28:23 +0000 (+0000) Subject: [Bug #953177] Mention .getlist(); text from Paul Moore X-Git-Tag: v2.4a1~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=44cbfd7819fcc40209d8bcb960eccfa7237b1717;p=thirdparty%2FPython%2Fcpython.git [Bug #953177] Mention .getlist(); text from Paul Moore --- diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex index a14717ac887a..3cb07b2da3dd 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