Python & PEP All In One
Python & PEP All In One
Python Enhancement Proposals /
Python 增强建议
demos
PEP 8– Style Guide for Python Code
4 spaces indentation / 4 空格缩进 (💩 浪费编辑器一行的空间,限制最大 80字符一行)
# Correct: ✅
# 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)
# Wrong: ❌
# 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)

https://peps.python.org/pep-0008/
PEP 279– The enumerate() built-in function
https://peps.python.org/pep-0279/
refs
©xgqfrms 2012-2021
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
未经授权禁止转载,违者必究!