This article is part of in the series

Tabnanny is a module in Python that checks your source code for ambiguous indentation. This module is useful because in Python, white space isn't supposed to be ambiguous, and if your source code contains any weird combinations of tabs and spaces, tabnanny will let you know.

You can run tabnanny in one of two ways, either by using the command line, or by running it within your program. Running it from the command line would look something like this:

$ python -m tabnanny .

This will yield you results that specify which file and which line an error has been found in. If you want to see more info about all the files that are being scanned, use the -v option when writing your command:

$ python -m tabnanny -v .

To run tabnanny from within your program, you'll need to use it with the function .check(), which should look something like this:

import sys
import tabnanny


As long as you use tabnanny to check all your code, you should never have any issues with indentation errors. Since the process is usually very quick and requires hardly any coding to accomplish, it's kind of a no-brainer.