1. Why does PyCharm use 120 character lines, even though PEP8 specifies 79? ////////2. Python code is too long to wrap

Ask:

PEP8 explicitly specifies 79 characters, however, PyCharm defaults to 120 and gives the warning "PEP8: line too long (...> 120 characters)".

Does previous PEP8 version use 120 and PyCharm doesn't update its PEP8 checker? I can't find any PEP8 guides for previous versions, however, I can easily find PEP8 Python scripts for previous versions.

I'm starting a new Python project and I'm not sure which one to use.

references:

http://legacy.python.org/dev/peps/pep-0008/


answer:

PyCharm is built on IntelliJ. IntelliJ's default line length is 120 characters.

It's probably because you can't fit a normal Java name, eg: @annotated public static MyObjectFactoryFactory enterpriseObjectFactoryFactoryBuilderPattern {only 80 characters. (I like it, but Java names tend to get longer by convention).

The pep8 checker is configurable, so you can specify a better maximum line length - for example 79 characters.

The error is misleading because the pep8 checker uses a similar format to format the text "PEP8: line too long(... > %s characters)" % max_line_setting. So it uses the pep8 checker, with a specific configuration, instead of claiming that pep8 specifies 120 character lines.


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Python code wrapping is adding a \ after each line


Take a chestnut:

time = "2017"
print "one" + "," \
+ "two" \
+ ",three" + \
"," + time


It prints out:

one,two,three,2017


Take another chestnut:

print "this line is toooooooooooo \
long"


print it out:

this line is toooooooooooo long

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324693156&siteId=291194637