Two tiny clarifications.

This commit is contained in:
Guido van Rossum 2002-05-24 19:46:20 +00:00
parent 74d28aabb3
commit 78c759d636
1 changed files with 6 additions and 2 deletions

View File

@ -506,7 +506,8 @@ Programming Recommendations
'is' or 'is not'. Also, beware of writing "if x" when you
really mean "if x is not None" -- e.g. when testing whether a
variable or argument that defaults to None was set to some other
value.
value. The other value might be a value that's false in a
Boolean context!
- Class-based exceptions are always preferred over string-based
exceptions. Modules or packages should define their own
@ -554,7 +555,10 @@ Programming Recommendations
reindent.py) will trim them.
- Don't compare boolean values to True or False using == (bool
types are new in Python 2.3).
types are new in Python 2.3):
No: if greeting == True: print "Hello world"
Yes: if greeting: print "Hello world"
References