Python Rocks!

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Tue Jan 18 18:48:52 EST 2000


>>>>> "t" == tye  <tye4 at yahoo.com> writes:

    t> Only way around that would be not use tabs... which is quite
    t> ridiculous (I don't want to type 4 spaces for every line.)

Using tabs in Python source is fine if you follow one very simple
rule: your tab width must be equal to the number of spaces you indent
for a block.  Thus if you indent 4 spaces per level and your tab width
is equal to 4 spaces, you can use tabs everywhere.  If you indent 4
spaces but your tab width is 8 spaces, you should not use tabs in the
indentation.

This implies that you should never mix tabs and spaces for indentation
in Python source code.  The above is the rule followed by Emacs'
Python mode (see py-smart-indentation).

-Barry




More information about the Python-list mailing list