Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PEP8 E226 recommendation

Tags:

python

pep8

The E226 error code is about "missing whitespace around arithmetic operator".

I use Anaconda's package in Sublime which will highlight as a PEP8 E226 violation for example this line:

hypot2 = x*x + y*y

But in Guido's PEP8 style guide that line is actually shown as an example of recommended use of spaces within operators.

Question: which is the correct guideline? Always spaces around operators or just in some cases (as Guido's recommendation shows)?

Also: who decides what goes into PEP8? I would've thought Guido's recommendation would pretty much determine how that works.

like image 664
Gabriel Avatar asked Apr 22 '16 12:04

Gabriel


1 Answers

The maintainers of the PEP8 tool decide what goes into it.

As you noticed, these do not always match the PEP8 style guide exactly. In this particular case, I don't know whether it's an oversite by the maintainers, or a deliberate decision. You'd have to ask them to find out, or you might find the answer in the commit history.

Guido recently asked the maintainers of pep8 and pep257 tools to rename them, to avoid this confusion. See this issue for example. As a result, the tools are getting renamed to pycodestyle and pydocstyle, respectively.

like image 168
Alasdair Avatar answered Sep 30 '22 04:09

Alasdair