Commit 7fc214b5 authored by Ezio Melotti's avatar Ezio Melotti

#6423 has_key -> in

parent 46ca2f25
...@@ -91,12 +91,13 @@ form contents from standard input or the environment (depending on the value of ...@@ -91,12 +91,13 @@ form contents from standard input or the environment (depending on the value of
various environment variables set according to the CGI standard). Since it may various environment variables set according to the CGI standard). Since it may
consume standard input, it should be instantiated only once. consume standard input, it should be instantiated only once.
The :class:`FieldStorage` instance can be indexed like a Python dictionary, and The :class:`FieldStorage` instance can be indexed like a Python dictionary.
also supports the standard dictionary methods :meth:`has_key` and :meth:`keys`. It allows membership testing with the :keyword:`in` operator, and also supports
The built-in :func:`len` is also supported. Form fields containing empty the standard dictionary method :meth:`keys` and the built-in function
strings are ignored and do not appear in the dictionary; to keep such values, :func:`len`. Form fields containing empty strings are ignored and do not appear
provide a true value for the optional *keep_blank_values* keyword parameter when in the dictionary; to keep such values, provide a true value for the optional
creating the :class:`FieldStorage` instance. *keep_blank_values* keyword parameter when creating the :class:`FieldStorage`
instance.
For instance, the following code (which assumes that the For instance, the following code (which assumes that the
:mailheader:`Content-Type` header and blank line have already been printed) :mailheader:`Content-Type` header and blank line have already been printed)
...@@ -104,7 +105,7 @@ checks that the fields ``name`` and ``addr`` are both set to a non-empty ...@@ -104,7 +105,7 @@ checks that the fields ``name`` and ``addr`` are both set to a non-empty
string:: string::
form = cgi.FieldStorage() form = cgi.FieldStorage()
if not (form.has_key("name") and form.has_key("addr")): if "name" not in form or "addr" not in form:
print "<H1>Error</H1>" print "<H1>Error</H1>"
print "Please fill in the name and addr fields." print "Please fill in the name and addr fields."
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment