diff options
author | Collin Winter <collinw@gmail.com> | 2007-09-01 23:34:30 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-09-01 23:34:30 (GMT) |
commit | c79461b1648c9209c3652184572a17eef0a76202 (patch) | |
tree | 47c6238c8c47c4881f6f0523ea86d201cea1fc94 /Doc/library/cgi.rst | |
parent | 2ac012130549b1ef51ebce11148d01eaca1a7033 (diff) | |
download | cpython-c79461b1648c9209c3652184572a17eef0a76202.zip cpython-c79461b1648c9209c3652184572a17eef0a76202.tar.gz cpython-c79461b1648c9209c3652184572a17eef0a76202.tar.bz2 |
Partial py3k-ification of Doc/library/: convert has_key references into either 'k in d' or __contains__; normalize raise statements; convert print statements into print function calls.
Diffstat (limited to 'Doc/library/cgi.rst')
-rw-r--r-- | Doc/library/cgi.rst | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst index 98166e8..d2b88aa 100644 --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -91,11 +91,11 @@ 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:`has_key` 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. +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. For instance, the following code (which assumes that the :mailheader:`Content-Type` header and blank line have already been printed) @@ -103,7 +103,7 @@ checks that the fields ``name`` and ``addr`` are both set to a non-empty string:: form = cgi.FieldStorage() - if not (form.has_key("name") and form.has_key("addr")): + if not ("name" in form and "addr" in form): print "<H1>Error</H1>" print "Please fill in the name and addr fields." return |