Insert a blank line before and after all docstrings (one-line or multi-line) that document a class -- generally speaking, the class's methods are separated from each other by a single blank line, and the docstring needs to be offset from the first method by a blank line; for symmetry, put a blank line between the class header and the docstring.
But I can't seem to find any code that actually implements this.
I've checked several standard modules delivered with Python 2.6, even searched specifically for ones where Guido's name is mentioned. But even the code of the rietveld code review tool does IMHO not comply (see e.g. http://code.google.com/p/rietveld/source/browse/upload.py):
class CondensedHelpFormatter(optparse.IndentedHelpFormatter):
"""Frees more horizontal space by removing indentation from group
options and collapsing arguments between short and long, e.g.
'-o ARG, --opt=ARG' to -o --opt ARG"""
def format_heading(self, heading):
return "%s:\n" % heading
This multi line docstring does not have a blank line in before and the blank line after is outside the closing quotes.
This class from /usr/lib64/python2.6/site.py
does not have a blank line before but has a blank line before and after the closing quotes.
class _Helper(object):
"""Define the built-in 'help'.
This is a wrapper around pydoc.help (with a twist).
"""
def __repr__(self):
Are there examples available to demonstrate PEP 257?
Thanks in advance