python-pep8


What is pep8 and what are pep8 errors in Python?

PEPs are Python Enhancement Proposals, and they describe and document the way python language evolves. They also provide a reference point (and a standard) for the pythonic way to write code. This is just the style guide for Python Code.

It was designed to help python developers write more readable code. You can read more about it in at our blog in a posts written by one of our Junior Developers PEP8, and why is it important? - Pragmatic Coders


summary

PEP8是一个关于Python的代码编写规范. 并不是语言层面的强制要求而是基于团队开发的考量人为进行的约定, 往远了说类似HTTP协议, 你我都遵循这个协议规范从而进行通信. 其他开发语言(Java, javascript, PHP)同样会有编码规范, 或者技术团队在开发的时候会先定好这个, 使得不同成员编写的代码有良好的可读性.

an example

PEP8 E251: unexpected spaces around keyword

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# YES
def myfunc(key1=val1, key2=val2, key3=val3)
# NO
def myfunc(key1 = val1, key2 = val2, key3 = val3)
# YES
def myfunc(key1=val1,
key2=val2,
key3=val3)
# YES
new_dict = Dict(
key1=val1,
key2=val2,
key3=val3
)
# NO
new_dict = Dict(
key1 = val1,
key2 = val2,
key3 = val3
)
# NO
new_dict = Dict(
key1=val1,
key2=val2,
key3=val3
)