“Pleasing the senses or mind aesthetically.” -- Oxford Dictionary
“A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is the most important.” -- PEP8
# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Add 4 spaces (an extra level of indentation)
# to distinguish arguments from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# Hanging indents should add a level.
foo = long_function_name(
var_one, var_two,
var_three, var_four)
# Arguments on first line forbidden
# when not using vertical alignment.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Further indentation required
# as indentation is not distinguishable.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
“The limits are chosen to avoid wrapping in editors with the window width set to 80.” -- PEP8
pylint
flake8
def foo(bar):
print("hello "+bar)
def baz():
print("Testing 1 2 1 2")
foo()
************* Module example
example.py:1:0: C0111: Missing module docstring (missing-docstring)
example.py:1:0: C0102: Black listed name "foo" (blacklisted-name)
example.py:1:0: C0102: Black listed name "bar" (blacklisted-name)
example.py:1:0: C0111: Missing function docstring (missing-docstring)
example.py:4:0: C0102: Black listed name "baz" (blacklisted-name)
example.py:4:0: C0111: Missing function docstring (missing-docstring)
example.py:7:0: E1120: No value for argument 'bar' in function call (no-value-for-parameter)
def foo(bar):
print("hello " + bar)
def baz():
print("Testing 1 2 1 2")
foo()