summaryrefslogtreecommitdiffstats
path: root/Doc/library/cgi.rst
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2009-07-22 21:17:14 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2009-07-22 21:17:14 (GMT)
commitc7e994d00976f3890406394c8f23804b245b2693 (patch)
treee1a87d4ded7b28bb96630754cda1351fb141d4a9 /Doc/library/cgi.rst
parentba13bd9603113b3edfd2b864465675bf63a2194f (diff)
downloadcpython-c7e994d00976f3890406394c8f23804b245b2693.zip
cpython-c7e994d00976f3890406394c8f23804b245b2693.tar.gz
cpython-c7e994d00976f3890406394c8f23804b245b2693.tar.bz2
Merged revisions 74179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74179 | ezio.melotti | 2009-07-23 00:08:49 +0300 (Thu, 23 Jul 2009) | 1 line #6423 has_key -> in ........
Diffstat (limited to 'Doc/library/cgi.rst')
-rw-r--r--Doc/library/cgi.rst15
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst
index 42acdcf..48932d5 100644
--- a/Doc/library/cgi.rst
+++ b/Doc/library/cgi.rst
@@ -88,12 +88,13 @@ input or the environment (depending on the value of various environment
variables set according to the CGI standard). Since it may consume standard
input, it should be instantiated only once.
-The :class:`FieldStorage` instance can be indexed like a Python dictionary, and
-also supports the standard dictionary methods :meth:`__contains__` and
-:meth:`keys`. The built-in :func:`len` is also supported. Form fields
-containing empty strings are ignored and do not appear in the dictionary; to
-keep such values, provide a true value for the optional *keep_blank_values*
-keyword parameter when creating the :class:`FieldStorage` instance.
+The :class:`FieldStorage` instance can be indexed like a Python dictionary.
+It allows membership testing with the :keyword:`in` operator, and also supports
+the standard dictionary method :meth:`keys` and the built-in function
+:func:`len`. Form fields containing empty strings are ignored and do not appear
+in the dictionary; to keep such values, provide a true value for the optional
+*keep_blank_values* keyword parameter when creating the :class:`FieldStorage`
+instance.
For instance, the following code (which assumes that the
:mailheader:`Content-Type` header and blank line have already been printed)
@@ -101,7 +102,7 @@ checks that the fields ``name`` and ``addr`` are both set to a non-empty
string::
form = cgi.FieldStorage()
- if not ("name" in form and "addr" in form):
+ if "name" not in form or "addr" not in form:
print("<H1>Error</H1>")
print("Please fill in the name and addr fields.")
return