Python PEP8: Blank lines convention

user225312 picture user225312 · Jun 1, 2010 · Viewed 34k times · Source

I am interested in knowing what is the Python convention for newlines between the program parts? For example, consider this:

import os

def func1():

def func2():

What should be the ideal newline separation between:

  1. The import modules and the functions?
  2. The functions themselves?

I have read PEP8, but I wanted to confirm the above two points.

Answer

Bryan Oakley picture Bryan Oakley · Jun 1, 2010
  1. Two blank lines between the import statements and other code.
  2. Two blank lines between each function.