How to get TabError?

Mr. Magoo magoo at magoo.com
Sun Mar 27 12:29:16 EST 2005


In article <mailman.913.1111941223.1799.python-list at python.org>,
 "Fredrik Lundh" <fredrik at pythonware.com> wrote:

> "Mr. Magoo" wrote:
> 
> > Can someone provide a snippet which, when run, generates a TabError?
> >
> > I can only seem to get SyntaxError and IndentationError.
> 
> $ python -c "print repr(open('test.py').read())"
> 'if 1:\n\tprint "hello"\n        print "goodbye"\n'
> 
> $ python test.py
> hello
> goodbye
> 
> $ python -t test.py
> test.py: inconsistent use of tabs and spaces in indentation
> hello
> goodbye
> 
> $ python -tt test.py
>   File "test.py", line 3
>     print "goodbye"
>                   ^
> TabError: inconsistent use of tabs and spaces in indentation
> 
> </F> 


Thanks.

Is there a reason (good or otherwise :-) why py_compile dumps this and 
IndentationError in a different format than SyntaxError?

M



More information about the Python-list mailing list