ignore some errors
pep8 --ignore E501,E303 foo.py
The preferred way is to use a setup.cfg in the top-level of the project (.cfg has the same syntax as a .ini file), which should contain a [pep8] section. For example:
[pep8] ignore = E226,E302,E41 max-line-length = 160
The error codes are defined in http://pep8.readthedocs.org/en/latest/intro.html#error-codes
Where to put the import statements - beginning or middle?
https://www.python.org/dev/peps/pep-0008/#imports recommends to always import at the top of the file, just after any module comments and docstrings, and before module globals and constants.