Similar to tabnanny, is there a utility for python to check if a python file is using 4 spaces for indentation?
views:
90answers:
3
Q:
Similar to ``tabnanny``, how can I check that all the python code is using 4 spaces as an indent?
+4
A:
Pylint can check this among many other things. Here's a warning it gave me with a test file:
W: 3: Bad indentation. Found 3 spaces, expected 4
It's also possible to make it expect another indent type using this command line option:
--indent-string=<string>
String used as indentation unit. This is usually " "
(4 spaces) or "\t" (1 tab). [current: ' ']
interjay
2010-03-11 00:39:57
+4
A:
You can try the reindent.py script, found in tools/scripts of your python install.
Change Python (.py) files to use 4-space indents and no hard tab characters. Also trim excess spaces and tabs from ends of lines, and remove empty lines at the end of files. Also ensure the last line ends with a newline.
Dominic Bou-Samra
2010-03-11 00:41:15
+1
A:
Pylint (http://www.logilab.org/project/pylint) checks this (and much more).
Other Python code checkers (pep8, pyflakes, pychecker...) may do so too.
gurney alex
2010-03-11 06:53:18