I can not find the PEP link for this item. Should there be an empty string after the function definition?
Should I do this:
def hello_function(): return 'hello'
or shoud I do this:
def hello_function(): return 'hello'
The same question applies when docstrings are used:
def hello_function(): """ Important function """ return 'hello'
or
def hello_function(): """ Important function """ return 'hello'
EDIT
This is what PEP says on empty lines, as FoxMaSk commented, but it says nothing about this detail.
Empty lines
Separate the top-level functions and class definitions with two empty lines.
Method definitions within a class are separated by a single line space.
Extra blank lines can be used (sparingly) to separate groups of related functions. Empty lines may be omitted between the bundle (for example, a set of dummy implementations).
Use blank lines in functions sparingly to specify logical partitions.
Python accepts the feed character of the control form L (ie ^ L) as whitespace; Many tools treat these characters as page separators, so you can use them to separate pages from related sections of your file. Note that some code editors and web users cannot recognize control-L as form feeds and will show a different character.
python coding-style styles pep
bgusach
source share