Add note about how Control-L gets displayed. Fix whitespace.
This commit is contained in:
parent
3c6691491d
commit
bbc55dbeb2
12
pep-0008.txt
12
pep-0008.txt
|
@ -86,9 +86,9 @@ Code lay-out
|
||||||
The preferred way of wrapping long lines is by using Python's implied line
|
The preferred way of wrapping long lines is by using Python's implied line
|
||||||
continuation inside parentheses, brackets and braces. Long lines can be
|
continuation inside parentheses, brackets and braces. Long lines can be
|
||||||
broken over multiple lines by wrapping expressions in parentheses. These
|
broken over multiple lines by wrapping expressions in parentheses. These
|
||||||
should be used in preference to using a backslash for line continuation.
|
should be used in preference to using a backslash for line continuation.
|
||||||
Make sure to indent the continued line appropriately. The preferred place
|
Make sure to indent the continued line appropriately. The preferred place
|
||||||
to break around a binary operator is *after* the operator, not before it.
|
to break around a binary operator is *after* the operator, not before it.
|
||||||
Some examples:
|
Some examples:
|
||||||
|
|
||||||
class Rectangle(Blob):
|
class Rectangle(Blob):
|
||||||
|
@ -120,7 +120,9 @@ Code lay-out
|
||||||
|
|
||||||
Python accepts the control-L (i.e. ^L) form feed character as whitespace;
|
Python accepts the control-L (i.e. ^L) form feed character as whitespace;
|
||||||
Many tools treat these characters as page separators, so you may use them
|
Many tools treat these characters as page separators, so you may use them
|
||||||
to separate pages of related sections of your file.
|
to separate pages of related sections of your file. Note, some editors
|
||||||
|
and web-based code viewers may not recognize control-L as a form feed
|
||||||
|
and will show another glyph in its place.
|
||||||
|
|
||||||
Encodings (PEP 263)
|
Encodings (PEP 263)
|
||||||
|
|
||||||
|
@ -697,14 +699,14 @@ Programming Recommendations
|
||||||
try:
|
try:
|
||||||
import platform_specific_module
|
import platform_specific_module
|
||||||
except ImportError:
|
except ImportError:
|
||||||
platform_specific_module = None
|
platform_specific_module = None
|
||||||
|
|
||||||
A bare 'except:' clause will catch SystemExit and KeyboardInterrupt
|
A bare 'except:' clause will catch SystemExit and KeyboardInterrupt
|
||||||
exceptions, making it harder to interrupt a program with Control-C,
|
exceptions, making it harder to interrupt a program with Control-C,
|
||||||
and can disguise other problems. If you want to catch all
|
and can disguise other problems. If you want to catch all
|
||||||
exceptions that signal program errors, use 'except Exception:'.
|
exceptions that signal program errors, use 'except Exception:'.
|
||||||
|
|
||||||
A good rule of thumb is to limit use of bare 'except' clauses to two
|
A good rule of thumb is to limit use of bare 'except' clauses to two
|
||||||
cases:
|
cases:
|
||||||
|
|
||||||
1) If the exception handler will be printing out or logging
|
1) If the exception handler will be printing out or logging
|
||||||
|
|
Loading…
Reference in New Issue