Issue 26030: Use PEP8 in documentation examples (original) (raw)

Created on 2016-01-06 22:06 by mdk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg257649 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2016-01-06 22:06
Hi, Shouldn't Python use PEP8 in its examples in the documentation ? I found a lot of missing spaces around binary operators, and things like "setup (name = 'PackageName'," (found in the Distributing section, but that's just a single example) which hurt my eyes and will probably teach bad practices to newcomers reading it. If everybody agree documentation examples should be PEP8 compliant, I'll can gladly provide some patches. I also found http://bugs.python.org/issue23921 which is probably not merged as it's still open, and the patch don't fix my example, so there is probably some problems left.
msg257661 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-06 23:39
In general I agree with fixing style problems in the documentation, especially if you supply patches :)
msg257674 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-01-07 06:46
> I found a lot of missing spaces around binary operators Please don't make trivial changes like this.
msg257675 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-07 07:06
If it is fixing stuff like “lambda x: x +1” (from Issue 23921), I am in favour. But if the code example is self-consistent and uses a reasonable style, it should not be changed. Julien, perhaps you should give an example to clarify.
msg257676 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-01-07 07:16
No spaces around binary operator is OK in PEP8. See http://bugs.python.org/issue11425
msg257838 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-01-09 14:38
Without a list of places that don't follow the PEP8, I'm going to close this.
msg257841 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2016-01-09 16:02
I opened this ticket mainly to know the opinions on those modifications, I'll slowly review what I see, and provide little patches from time to time, only when the PEP8 infringement look obvious. I think the most obvious PEP8 infringement ARE to be fixed, typically in the tutorial: The documentation is where people learn, let's teach them the right thing to do :-) Thanks to naoki I just learnt that no spaces around binary operators are OK when it enhance the readability (https://www.python.org/dev/peps/pep-0008/#other-recommendations) like 2*2 + 3*2. I close this ticket, I'll just mention if I propose a patch in a new one. Bests.
msg257918 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-01-10 15:59
> I'll slowly review what I see, and provide little patches from > time to time, only when the PEP8 infringement look obvious. Sounds good to me. If you are not sure you can ask on IRC (#python-dev on freenode) or the core-mentorship mailing list.
History
Date User Action Args
2022-04-11 14:58:25 admin set github: 70218
2016-01-10 15:59:00 ezio.melotti set messages: +
2016-01-09 22:05:09 berker.peksag set stage: needs patch -> resolved
2016-01-09 16:02:58 mdk set status: pending -> closedmessages: +
2016-01-09 14:38:20 ezio.melotti set status: open -> pendingresolution: not a bugmessages: +
2016-01-08 17:34:27 ezio.melotti set nosy: + ezio.melottiversions: + Python 3.6
2016-01-07 07:16:09 methane set nosy: + methanemessages: +
2016-01-07 07:06:16 martin.panter set messages: +
2016-01-07 06:46:45 rhettinger set nosy: + rhettingermessages: +
2016-01-06 23:39:46 martin.panter set nosy: + martin.pantermessages: + stage: needs patch
2016-01-06 22:06:04 mdk create