[issue16239] PEP8 arithmetic operator examples
Ezio Melotti added the comment: Thanks! FTR, this is the changeset: http://hg.python.org/peps/rev/16dd63848921 -- stage: patch review - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Éric Araujo added the comment: One idiom is not covered by the examples: value = seq[something+1] IMO it feels weird to put spaces in an index/slice notation. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Guido van Rossum added the comment: That example doesn't feel strong enough to me to include in the style guide. I am fine with leaving that up to the individual contributor to decide. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Guido van Rossum added the comment: Wow. Someone edited that to be completely against my guidance. I'll fix it according to my intentions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Changes by Guido van Rossum gu...@python.org: -- assignee: ezio.melotti - gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Guido van Rossum added the comment: Corrected to: Yes:: i = i + 1 submitted += 1 x = x*2 - 1 hypot2 = x*x + y*y c = (a+b) * (a-b) No:: i=i+1 submitted +=1 x = x * 2 - 1 hypot2 = x * x + y * y c = (a + b) * (a - b) -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
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 rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Ezio Melotti added the comment: Attached a patch that modifies some of the example in the section. - x = x * 2 - 1 - hypot2 = x * x + y * y + x = x*2 - 1 + hypot2 = x*x + y*y Here I used more space around operators with lower priority. - x = x*2 - 1 - hypot2 = x*x + y*y - c = (a+b) * (a-b) + x = x * 2-1 + hypot2 = x*x + y * y + c = a+b * a-b These 3 examples in the No section show respectively: 1) more space around the operator with higher priority; 2) inconsistent spacing around operators with the same priority; 3) misleading spacing (similar to 1); I don't think it's necessary to mention 'x * 2 - 1' in either sections, because it's not wrong, but otoh 'x*2 - 1' is a better alternative. -- assignee: docs@python - ezio.melotti keywords: +patch nosy: +ezio.melotti stage: - patch review Added file: http://bugs.python.org/file27713/issue16239.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Serhiy Storchaka added the comment: - x = x * 2 - 1 - hypot2 = x * x + y * y Why you remove this? - c = (a+b) * (a-b) + c = a+b * a-b This changes the semantic. but otoh 'x*2 - 1' is a better alternative. Can you justify this? -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Ezio Melotti added the comment: - x = x * 2 - 1 - hypot2 = x * x + y * y Why you remove this? As I explained in my previous message, even if valid, these are IMHO less clear than x*2 - 1 and x*x + y*y. - c = (a+b) * (a-b) + c = a+b * a-b This changes the semantic. It does indeed, but I think it's worth pointing out that misleading spacing should be avoided. Maybe a different example could be used. but otoh 'x*2 - 1' is a better alternative. Can you justify this? x*2 - 1 gives a visual hint of what gets executed first, x * 2-1 gives a wrong/misleading hint of what gets executed first, x * 2 - 1 gives no hint at all. I think that providing the correct hint is better than not providing any hints (and clearly better than providing the wrong hint!). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Serhiy Storchaka added the comment: As I explained in my previous message, even if valid, these are IMHO less clear than x*2 - 1 and x*x + y*y. I don't feel this. Anyone else feel this? It seems to me, this is a serious change in the Style Guide. It does indeed, but I think it's worth pointing out that misleading spacing should be avoided I think this example shows that even without misleading such spacing is not good. The destructiveness of misleading spacing is evident for all. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Ezio Melotti added the comment: As I see it: For c = (a + b) * (a - b) the hint (and the actual priority) is given by the (), the spaces around the +/- are not necessary but don't affect readability. For c = (a+b) * (a-b) the hints are given both by the () and the spacing, the lack of spaces around the +/- is not necessary but doesn't affect readability. For c = a+b * a-b the hints are given both by the spacing and they are wrong. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
New submission from Peter Würtz: I think the PEP8 examples for arithmetic expressions are a bit misleading. (http://www.python.org/dev/peps/pep-0008/#id20) The text clearly says that it should add spaces around operators of low(est) priority, which means that I'm encouraged to visually group an expression of high priority. It doesn't say (anymore?) that there should always be spaces around all arithmetic operators. This is however not reflected in the examples. In the examples x = x*2 - 1 is listed as a negative example, while being perfectly compliant with the guide. Shouldn't this be in the Yes or an Optionally example block? I believe these examples may cause some people to interpret the style guide in a very rigid way, eventually leading to PEP8 formatting tools that flatten out nicely grouped expressions. -- assignee: docs@python components: Documentation messages: 172965 nosy: docs@python, pwuertz priority: normal severity: normal status: open title: PEP8 arithmetic operator examples type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16239] PEP8 arithmetic operator examples
Raymond Hettinger added the comment: Shouldn't this be in the Yes or an Optionally example block? +1 -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16239 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com