This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PEP 257: drop the recommendation for a blank line between the class line and the docstring
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: akitada, gvanrossum, r.david.murray
Priority: normal Keywords: patch

Created on 2014-10-24 14:38 by akitada, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pep-0257.patch akitada, 2014-10-24 14:38
pep-0257.patch akitada, 2014-10-24 15:43
Messages (6)
msg229921 - (view) Author: Akira Kitada (akitada) * Date: 2014-10-24 14:38
The PEP 257 says:

   Insert a blank line before and after all docstrings (one-line or multi-line)
   that document a class


Looking at stdlib and popular open source software, I couldn't find packages that follow this style, so I think this is not really a convention.
msg229922 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-24 14:52
I follow this recommendation.  I'm sure there are many classes in the stdlib that do not follow this convention, since much of the stdlib was written before PEP8, and we don't go back and do changesets just to "fix" PEP8 non-conformance in the stdlib.  But this is the preferred style, and new code in the stdlib should follow it.  Whether anyone else does is up to them.

(For that matter, there are a lot of classes in the stdlib, especially the test suite, where the first 'def' follows the class line with no space in between, and I wince every time I read such code :)
msg229925 - (view) Author: Akira Kitada (akitada) * Date: 2014-10-24 15:06
Guido is with me :)

On Wed, Oct 22, 2014 at 2:16 AM, Guido van Rossum <guido at python.org> wrote:
> I think the argument is about the blank line between the "class" line and
> the docstring. I agree with Akira that very few packages follow this style,
> and I think we would do well to remove this recommendation. There's no point
> in fighting the prevailing convention.
msg229931 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-24 15:20
Yeah, on reflection (after I posted) I can see why people tend to leave out that blank line, because it is more parallel to not having a blank line after the 'def'.  And I don't think I've ever seen anyone do the alternate version of keeping things parallel by putting a blank line before the docstring if the method has multiple sections, despite the recommendation in the PEP to do so.

However, you then need to delete the "if a method is written as a number of sections" sentence, since it has the same problem (it is recommending a blank line before the docstring, which nobody does...I didn't remember that recommendation at all myself).
msg229933 - (view) Author: Akira Kitada (akitada) * Date: 2014-10-24 15:43
Good point. I looked at some Python files but, as you pointed out,
I couldn't find ones what follow the recommendation.
In some files there is a blank line after a docstring but it seemed
it's not because it "is written as a number of sections".

The patch updated.
msg229939 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-10-24 16:32
I've applied the second version -- rev 9b715d8246db in the peps repo.
History
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66904
2014-10-24 20:29:18berker.peksagsetstage: needs patch -> resolved
2014-10-24 16:32:45gvanrossumsetnosy: + gvanrossum
messages: + msg229939

assignee: gvanrossum
resolution: not a bug -> fixed
2014-10-24 15:43:39akitadasetstatus: open -> closed
files: + pep-0257.patch
resolution: not a bug
messages: + msg229933
2014-10-24 15:20:18r.david.murraysetstatus: closed -> open
resolution: not a bug -> (no value)
messages: + msg229931

stage: resolved -> needs patch
2014-10-24 15:06:35akitadasetmessages: + msg229925
2014-10-24 14:52:04r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg229922

resolution: not a bug
stage: resolved
2014-10-24 14:38:25akitadacreate