You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/birkenfeld'closed_at=<Date2008-12-13.02:59:56.539>created_at=<Date2008-12-13.00:53:27.501>labels= ['docs']
title='Fix a+b to a + b'updated_at=<Date2008-12-13.16:07:33.280>user='https://bugs.python.org/Retro'
Let's set a good example in the documentation and follow PEP-8. For
God's sake, this is the documentation of Python! Where else to set a
good example than here? Let's see some PEP-8 in action, in the
documentation!
lambertdw commented on Dec 13, 2008
lambertdwmannequin
Mannequin
More actions
That phrase of PEP-8 means to me "Use spaces to visually group
expressions according to precedence."
What is recommended in PEP-8, you are engouraged to follow that; not you
as a Python coder but you as a member of the Python community where PEP-8 is the coding style specification. Python's built-in modules have such
a lovely coding style because they all follow PEP-8. Why must the
documentation be an exception not to follow PEP-8? Is there a technical
reason? And the lack of space is not an issue. PEP-8 makes it clear to
"use spaces around arithmetic operators" and then it gives some examples
what is acceptable and what is not. Let us look at this again, shall we?
Yes:
i = i + 1
No:
i=i+1
Let us convert this into our version from the example code:
Yes:
a, b = b, a + b
No:
a,b=b,a+b
Only the a+b part is not written according to PEP-8. Python beginners
don't start learning the language by first reading PEP-8. They don't
even know it exists; and since they are beginners, talking about the
coding style is too soon. What they do first is read the Python tutorial
and they look at how code is written in the tutorial and get used to
that. And so if the code is badly written there, they will also write
bad code (bad as in 'with a bad coding style'). So we must set an
example for Python beginners (and also other people) to write
good-coding-style code. So my point is that people won't need to read PEP-8 if that is applied into the documentation (especially the
tutorial); they'll just look at some example code and know how to write
code. Please fix those things like a+b to a + b and n//x to n // x.
I have added mister van Rossum into this issue report, because I think
we need a BDFL opinion. What do you think, mister van Rossum, about this?
Retro, you are blowing this way out of proportion. Style guidelines are
not absolute rules that must be followed at all cost, and there are
always exceptions. You need to have a lot of experience before you can
claim with certainty that a certain piece of code should or should not
be formatted according to the style guidelines. (This is as opposed to
the syntax of the language, which is an absolute set of rules where
violations raise a SyntaxError.)
In this case, the PEP never meant to say that all arithmetic operators
have to be surrounded by spaces. That would make just as little sense
as requiring no spaces. The words in the PEP cannot possibly
approximate the set of heuristics I have in my mind for this purpose,
and I don't think they have to. When I wrote PEP-8 (or actually its
precursor), I was merely *suggesting* that certain uses of spaces look
better than others. If you are interpreting this as requiring all
examples needing to follow the literal style guide, well, Im sorry, but
that's not how it was meant, and I am not willing to either change the
examples (the specific one you quote looks just fine to me) or to edit
the PEP to try and formulate a more complex rule. In my experience, the
more baroque the rule the more arguments it elicits.
Activity
Retro commentedon Dec 13, 2008
http://docs.python.org/3.0/tutorial/controlflow.html#defining-functions
Please visit the above link and see line 6 in the example code.
... a, b = b, a+b
should be fixed to
... a, b = b, a + b
because PEP-8 recommends to
Yes:
i = i + 1
No:
i=i+1
Retro commentedon Dec 13, 2008
And please fix the code example mentioned in bpo-4648.
Line 4 has a little fix to be made:
from
... print(n, 'equals', x, '*', n//x)
to
... print(n, 'equals', x, '*', n // x)
lambertdw commentedon Dec 13, 2008
I do think your interpretation of PEP-8 is overly strict. Here's the
source code of the first j interpreter. (Ken Iverson)
main(){C s[99];while(gets(s))pr(ex(wd(s)));}
Retro commentedon Dec 13, 2008
Let's set a good example in the documentation and follow PEP-8. For
God's sake, this is the documentation of Python! Where else to set a
good example than here? Let's see some PEP-8 in action, in the
documentation!
lambertdw commentedon Dec 13, 2008
That phrase of PEP-8 means to me "Use spaces to visually group
expressions according to precedence."
rhettinger commentedon Dec 13, 2008
This is silly. The current version better communicates its intended
purpose.
Retro commentedon Dec 13, 2008
What is recommended in PEP-8, you are engouraged to follow that; not you
as a Python coder but you as a member of the Python community where PEP-8 is the coding style specification. Python's built-in modules have such
a lovely coding style because they all follow PEP-8. Why must the
documentation be an exception not to follow PEP-8? Is there a technical
reason? And the lack of space is not an issue. PEP-8 makes it clear to
"use spaces around arithmetic operators" and then it gives some examples
what is acceptable and what is not. Let us look at this again, shall we?
Let us convert this into our version from the example code:
Only the a+b part is not written according to PEP-8. Python beginners
don't start learning the language by first reading PEP-8. They don't
even know it exists; and since they are beginners, talking about the
coding style is too soon. What they do first is read the Python tutorial
and they look at how code is written in the tutorial and get used to
that. And so if the code is badly written there, they will also write
bad code (bad as in 'with a bad coding style'). So we must set an
example for Python beginners (and also other people) to write
good-coding-style code. So my point is that people won't need to read
PEP-8 if that is applied into the documentation (especially the
tutorial); they'll just look at some example code and know how to write
code. Please fix those things like a+b to a + b and n//x to n // x.
I have added mister van Rossum into this issue report, because I think
we need a BDFL opinion. What do you think, mister van Rossum, about this?
gvanrossum commentedon Dec 13, 2008
Retro, you are blowing this way out of proportion. Style guidelines are
not absolute rules that must be followed at all cost, and there are
always exceptions. You need to have a lot of experience before you can
claim with certainty that a certain piece of code should or should not
be formatted according to the style guidelines. (This is as opposed to
the syntax of the language, which is an absolute set of rules where
violations raise a SyntaxError.)
In this case, the PEP never meant to say that all arithmetic operators
have to be surrounded by spaces. That would make just as little sense
as requiring no spaces. The words in the PEP cannot possibly
approximate the set of heuristics I have in my mind for this purpose,
and I don't think they have to. When I wrote PEP-8 (or actually its
precursor), I was merely *suggesting* that certain uses of spaces look
better than others. If you are interpreting this as requiring all
examples needing to follow the literal style guide, well, Im sorry, but
that's not how it was meant, and I am not willing to either change the
examples (the specific one you quote looks just fine to me) or to edit
the PEP to try and formulate a more complex rule. In my experience, the
more baroque the rule the more arguments it elicits.