pylint: don't warn about tabs

skip at pobox.com skip at pobox.com
Sat Mar 10 00:50:16 CET 2007


    Alan> "Ben Finney" <bignose+hates-spam at benfinney.id.au> wrote in message
    Alan> news:mailman.4813.1173388535.32031.python-list at python.org...
    >> Sticking to spaces for indentation avoids the ambiguity of
    >> interpretation that ASCII TAB characters are subject to.

    Alan> What ambiguity?
    Alan> Tabs are *less* ambiguous.
    Alan> One tab character is one level of indentation.
    Alan> I have never seen this violated.

The ambiguity comes when eventually your source is edited by someone else.
Perhaps you have the discipline to use only spaces or only tabs, but the guy
in the next cubicle is as likely to use spaces as you are to use tabs.  Once
he edits a file the two of you share, you're toast.

This is not a new topic.  After a lot of discussion over the years the
general consensus in the Python community is that spaces are the only way to
go.  Here are some references:

    http://www.python.org/dev/peps/pep-0666/
    http://mail.python.org/pipermail/python-list/2003-January/183758.html
    http://wiki.w4py.org/spaces-not-tabs.html

The Python distribution even comes with two scripts, tabnanny and reindent,
which were developed to detect and eliminate the ambiguity caused by mixing
spaces and tabs.  The beginning of the reindent doc string reads:

    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.

If only tabs were considered to be a viable alternative to only spaces,
reindent would almost certainly have grown a flag by now to allow that.

The tag line for tabnanny reads:

    The Tab Nanny despises ambiguous indentation.  She knows no mercy.

Finally, note this from PEP 666:

    The problem is that there is no polite way to say 'Stop wasting your
    valuable time and mine.'

That's as politely as I can put it.

Skip



More information about the Python-list mailing list