Two tiny clarifications.
This commit is contained in:
parent
74d28aabb3
commit
78c759d636
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue