[Python-checkins] peps: PEP 8 updates on hanging continuation lines, based on discussion from
barry.warsaw
python-checkins at python.org
Mon Jun 13 18:48:40 CEST 2011
http://hg.python.org/peps/rev/00f8e3bb1197
changeset: 3887:00f8e3bb1197
user: Barry Warsaw <barry at python.org>
date: Mon Jun 13 12:48:33 2011 -0400
summary:
PEP 8 updates on hanging continuation lines, based on discussion from
python-ideas (contributed by Steven Klass).
files:
pep-0008.txt | 32 +++++++++++++++++++++-----------
1 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/pep-0008.txt b/pep-0008.txt
--- a/pep-0008.txt
+++ b/pep-0008.txt
@@ -57,28 +57,38 @@
For really old code that you don't want to mess up, you can continue to
use 8-space tabs.
- Continuation lines should align wrapped elements either vertically using
- Python's implicit line joining inside parentheses, brackets and braces,
- or using a hanging indent of double your code indention, in which case
- there should be no argument on the first line. For example:
+ Continuation lines should align wrapped elements either vertically using
+ Python's implicit line joining inside parentheses, brackets and braces, or
+ using a hanging indent. When using a hanging indent the following
+ considerations should be applied; there should be no arguments on the
+ first line and further indentation should be used to clearly distinguish
+ itself as a continuation line.
Yes: # Aligned with opening delimiter
foo = long_function_name(var_one, var_two,
var_three, var_four)
- # Double code indention for hanging indent; nothing on first line
- foo = long_function_name(
+ # More indentation included to distinguish this from the rest.
+ def long_function_name(
var_one, var_two, var_three,
- var_four)
+ var_four):
+ print(var_one)
- No: # Stuff on first line forbidden
+ No: # Arguments on first line forbidden when not using vertical alignment
foo = long_function_name(var_one, var_two,
var_three, var_four)
- # 2-space hanging indent forbidden
+ # Further indentation required as indentation is not distinguishable
+ def long_function_name(
+ var_one, var_two, var_three,
+ var_four):
+ print(var_one)
+
+ Optional:
+ # Extra indentation is not necessary.
foo = long_function_name(
- var_one, var_two, var_three,
- var_four)
+ var_one, var_two,
+ var_three, var_four)
Tabs or Spaces?
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list