[Python-checkins] r86849 - peps/trunk/pep-0008.txt

michael.foord python-checkins at python.org
Sun Nov 28 20:45:16 CET 2010


Author: michael.foord
Date: Sun Nov 28 20:45:15 2010
New Revision: 86849

Log:
Modify the advice on line continuations to not recommend backslashes.
As discussed with Guido.
Also remove references to Python 2.0, 2.1 and 2.2

Modified:
   peps/trunk/pep-0008.txt

Modified: peps/trunk/pep-0008.txt
==============================================================================
--- peps/trunk/pep-0008.txt	(original)
+++ peps/trunk/pep-0008.txt	Sun Nov 28 20:45:15 2010
@@ -84,19 +84,20 @@
     limiting the length to 72 characters is recommended.
 
     The preferred way of wrapping long lines is by using Python's implied line
-    continuation inside parentheses, brackets and braces.  If necessary, you
-    can add an extra pair of parentheses around an expression, but sometimes
-    using a backslash looks better.  Make sure to indent the continued line
-    appropriately.  The preferred place to break around a binary operator is
-    *after* the operator, not before it.  Some examples:
+    continuation inside parentheses, brackets and braces.  Long lines can be
+    broken over multiple lines by wrapping expressions in parentheses. These
+    should be used in preference to using a backslash for line continuation.  
+    Make sure to indent the continued line appropriately.  The preferred place
+    to break around a binary operator is *after* the operator, not before it.  
+    Some examples:
 
     class Rectangle(Blob):
 
         def __init__(self, width, height,
                      color='black', emphasis=None, highlight=0):
-            if width == 0 and height == 0 and \
-               color == 'red' and emphasis == 'strong' or \
-               highlight > 100:
+            if (width == 0 and height == 0 and
+                color == 'red' and emphasis == 'strong' or
+                highlight > 100):
                 raise ValueError("sorry, you lose")
             if width == 0 and height == 0 and (color == 'red' or
                                                emphasis is None):
@@ -768,18 +769,6 @@
 
         if isinstance(obj, basestring):
 
-      In Python 2.2, the types module has the StringTypes type defined for
-      that purpose, e.g.:
-
-        from types import StringTypes
-        if isinstance(obj, StringTypes):
-
-      In Python 2.0 and 2.1, you should do:
-
-        from types import StringType, UnicodeType
-        if isinstance(obj, StringType) or \
-           isinstance(obj, UnicodeType) :
-
     - For sequences, (strings, lists, tuples), use the fact that empty
       sequences are false.
 


More information about the Python-checkins mailing list