Simplify an example based on comment from Thomas Holenstein <thomas@hex.ch>:

Do not use an extra flag variable to test only once in one subsequent if
statement.
This commit is contained in:
Fred Drake 2001-06-29 14:59:01 +00:00
parent 52b8c29ca7
commit 9f9bd6af78
1 changed files with 1 additions and 4 deletions

View File

@ -89,10 +89,7 @@ non-empty string:
\begin{verbatim} \begin{verbatim}
form = cgi.FieldStorage() form = cgi.FieldStorage()
form_ok = 0 if not (form.has_key("name") and form.has_key("addr")):
if form.has_key("name") and form.has_key("addr"):
form_ok = 1
if not form_ok:
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