Python PEP: empty string after function definition?

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.

+7
python coding-style styles pep
source share
3 answers

Read the Docstring Conventions .

It says that even if the function is really obvious, you need to write a single line docstring. And he says that:

There is no empty line before or after the dock.

So, I would encode something like

 def hello_function(): """Return 'hello' string.""" return 'hello' 
+10
source share

As @moliware pointed out, Docstring Conventions in the Single Line Docstrings section:

There is no empty line before or after the dock.

HOWEVER, he also says (under Multiline Docstrings ):

Insert an empty line after all docstrings (single-line or multi-line) that document the class - generally speaking, class methods are separated from each other by one empty line, and docstring must be shifted from the first method to an empty line.

My interpretation of all this: empty lines should never precede any docstring and should only follow docstring when it is for a class.

+6
source share

this is PEP 0008 which explains the whole coding standard

-2
source share

All Articles