Wednesday, May 20, 2020

Quicktip: Reindent Python Scripts

Suppose part of a python file uses spaces for indentation, while another part uses tabs. This will throw up exceptions at runtime. So the question is how to fix it.

One answer is to use the python script Stick it in some folder (~/bin/) in the default path and make it executable (chmod +x

The usage is straightforward:

reindent -n

modifies the original file in place.