This is an old copy of the Python FAQ. The information here may be outdated.

How do I keep editors from inserting tabs into my Python source?

The FAQ does not recommend using tabs, and the Python style guide (PEP 8) recommends 4 spaces for distributed Python code; this is also the Emacs python-mode default.

Under any editor, mixing tabs and spaces is a bad idea. MSVC is no different in this respect, and is easily configured to use spaces: Take Tools -> Options -> Tabs, and for file type “Default” set “Tab size” and “Indent size” to 4, and select the “Insert spaces” radio button.

If you suspect mixed tabs and spaces are causing problems in leading whitespace, run Python with the -t switch or run tabnanny to check a directory tree in batch mode:

python -m tabnanny .

The Tools/scripts/reindent.py tool can fix the indentation for one or more py-files, directories, or an entire directory tree.

python \Python25\Tools\Scripts\reindent.py directory

(This script is used to make sure that the Python source code is properly indented, so it should be pretty reliable.)

CATEGORY: windows

 

A Django site. rendered by a django application. hosted by webfaction.