In order to check errors in python formatting, use pep8 (installed with pip). In order to correct these errors automatically, use autopep8.
Posts tagged with formatting
In order to format paragraphs in text files or in comments in code, use the par program. It seems to be exactly what I need in many cases.