[Python-checkins] python/nondist/peps pep-0008.txt,1.9,1.10
bwarsaw@users.sourceforge.net
bwarsaw@users.sourceforge.net
2002年5月24日 12:39:50 -0700
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv3401
Modified Files:
pep-0008.txt
Log Message:
More additions based on comments from Tim Peters, Neal Norwitz,
Gerhard Haring, and Guido van Rossum.
Index: pep-0008.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** pep-0008.txt 24 May 2002 17:07:17 -0000 1.9
--- pep-0008.txt 24 May 2002 19:39:47 -0000 1.10
***************
*** 501,507 ****
! Optimization and Other Programming Recommendations
! - class-based exceptions are always preferred over string-based
exceptions. Modules or packages should define their own
domain-specific base exception class, which should be subclassed
--- 501,513 ----
! Programming Recommendations
! - Comparisons to singletons like None should always be done with
! '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.
!
! - Class-based exceptions are always preferred over string-based
exceptions. Modules or packages should define their own
domain-specific base exception class, which should be subclassed
***************
*** 542,545 ****
--- 548,559 ----
sequences are false, so "if not seq" or "if seq" is preferable
to "if len(seq)" or "if not len(seq)".
+
+ - Don't write string literals that rely on significant trailing
+ whitespace. Such trailing whitespace is visually
+ indistinguishable and some editors (or more recently,
+ reindent.py) will trim them.
+
+ - Don't compare boolean values to True or False using == (bool
+ types are new in Python 2.3).