From b64e6dcf9d114b469ec397da54b6b5d6b923e7bc Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 26 Apr 2002 20:45:38 +0000 Subject: [PATCH] Be more consistent, both internally and with recommended practice (within the limits of Python 2.1). This closes SF bug #547953. --- Doc/lib/libcgi.tex | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex index 8ab562d8b21f..6fd8fdd7128c 100644 --- a/Doc/lib/libcgi.tex +++ b/Doc/lib/libcgi.tex @@ -111,16 +111,17 @@ name, the object retrieved by \samp{form[\var{key}]} is not a \class{FieldStorage} or \class{MiniFieldStorage} 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 -(i.e., when your HTML form contains multiple fields with the same -name), use the \function{type()} function to determine whether you -have a single instance or a list of instances. For example, here's -code that concatenates any number of username fields, separated by -commas: +If you expect this possibility (i.e., 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, here's code that concatenates any +number of username fields, separated by commas: \begin{verbatim} +from types import ListType + value = form.getvalue("username", "") -if type(value) is type([]): +if isinstance(value, ListType): # Multiple username fields specified usernames = ",".join(value) else: -- 2.47.3