[python] How to fix Python indentation

autopep8 -i script.py

Use autopep8

autopep8 automagically formats Python code to conform to the PEP 8 nullstyle guide. It uses the pep8 utility to determine what parts of the nullcode needs to be formatted. autopep8 is capable of fixing most of the nullformatting issues that can be reported by pep8.

pip install autopep8
autopep8 script.py    # print only
autopep8 -i script.py # write file