Tabbing/Spaces
Tim Peters
tim.one at home.com
Fri Jan 19 20:40:41 EST 2001
[Robert L Hicks]
> ...
> While reading the reference manual it denotes that 8 spaces is
> that standard for indentation.
Where? The Python compiler deals with a tab character by moving to the next
multiple-of-8 column, but that's just a (hardcoded) fact.
> However almost all the code (if not all) seems to use 4.
> What is the standard spacing on indentation?
The std for Python code in the distribution (more widely adhered to in the
upcoming 2.1 release) is:
one indent level is 4 columns
no hard tab characters (pure spaces)
Indeed, the program Tools/scripts/reindent.py exists to convert code to that
std, and will produce nothing else. That's also the default behavior of the
Emacs python-mode, and of IDLE.
A non-blessed alternative is to use:
one indent level is one hard tab character (pure tabs)
and than there's no way to guess how many columns the author believes an
indent level is.
*Mixing* tabs and spaces is insane in Python source.
or-in-any-other-text-file-that's-viewed-by-more-than-one-person-ly y'rs
- tim
More information about the Python-list
mailing list