How to fix Python indentation?

Sometimes, we want to fix Python indentation.

In this article, we’ll look at how to fix Python indentation.

How to fix Python indentation?

To fix Python indentation, we can use the reindent.py script in the Python’s Tools/scripts/ folder.

If it’s missing, we run

pip install reindent

to install it.

Then we run

reindent foo.py

to fix the indentation in the foo.py file.

Conclusion

To fix Python indentation, we can use the reindent.py script in the Python’s Tools/scripts/ folder.