[docs] [issue16239] PEP8 arithmetic operator examples

Peter Würtz report at bugs.python.org
Fri Oct 26 17:46:56 CEST 2012

Peter Würtz added the comment:

>> x * 2 - 1 is less clear than x*2 - 1
> I don't feel this.  Anyone else feel this? 

I strongly feel so. And if you don't take my word for it, just open any math book or look at any formula and recognize that it is the general consensus that the elements of a product are written close together whereas the spacing between two summands is considerably larger. Typically, the dots between products are omitted to reduce the spacing even further.

Trying to educate people to do otherwise is just weird, isn't it?

> It seems to me, this is a serious change in the Style Guide.

Actually it isn't. Even the current style guide says that there should be an increased amount of spacing around operators of low(est) priority. The serious change happened when the old rule "always use exactly one space around all arithmetic operators" fell, which certainly was a good call.

I've seen arguments on mailing lists whether to use x ** 2 + 1 instead of x**2 + 1 based on that rule. I hardly doubt that anyone prefers x ** 2 + 1 over x**2 + 1, so neither should the style guide.


Python tracker <report at bugs.python.org>

More information about the docs mailing list