Making tabs illegal

David Porter jcm at bigskytel.com
Mon Jul 10 18:06:49 EDT 2000


* Forrest Cahoon <fcahoon at my-deja.com>:

> I have heard of the -tt flag, but I don't think that's exactly what I'm
> looking for.  I'd like to enforce spaces and disallow tabs altogether.
> (What does "mixed in a dangerous way" mean, anyway?)

Mixing tabs and spaces (a tab here, four spaces there...) is the real
problem. Using tabs exclusively or spaces exclusively both work fine. So
this is what the -tt flag does:

~ > python -tt
Python 1.5.2 (#1, Jul 23 1999, 06:38:16)  [GCC egcs-2.91.66 19990314/Linux
(egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> for x in range(10):
...     print 'indented with four spaces'
...     print 'indented with one tab'
  File "<stdin>", line 3
    print 'indented with one tab'
                                ^
SyntaxError: inconsistent use of tabs and spaces in indentation
>>> 


> The issue is being able to enforce a particular coding style in a
> development environment.  For that reason, it's better to have it
> compiled in than to be a command-line switch.

Just enforce a particular editor, which converts tabs to four spaces
automagically. There are several which can do it. Then again, you have the
sources, so if you know c you can add the switch yourself. 




More information about the Python-list mailing list