I know there are tools which validate whether your Python code is compliant with PEP8, for example there is both an online service and a python module.
If you're using eclipse + PyDev you can simply activate autopep8 from PyDev's settings:
Windows -> Preferences -> type 'autopep8' in the search filter.
Check the 'use autopep8.py for code formatting?' -> OK
Now eclipse's CTRL-SHIFT-F code formatting should format your code using autopep8 :)