auto indent

John Machin sjmachin at
Tue Nov 7 01:46:46 CET 2006

M.N.Smadi wrote:
> Hi there;
> i have a script that is not indented properly. Is there a way that i can
> have it auto indented.

It depends on what you mean by "not indented properly". Indentation is
part of the Python grammar.

If the script compiles OK, and works as expected, but you have (say)
4-space indent in parts, and 3-space in other parts, or a mixture of
tabs and spaces, you could use the supplied reindent script. It's
C:\Python25\Tools\Scripts\ on my machine. Do read the
documentation at the start of the script before you run it.

If you mean that the indentation is just plain wrong, such that the
script will not compile without error, or incorrect indentation of one
or more lines is causing incorrect results, then you will have to fix
it manually. There is no "artificial intelligence" that can work out
what the indentation should be.


More information about the Python-list mailing list