How to get TabError?

Fredrik Lundh fredrik at pythonware.com
Sun Mar 27 18:34:03 CEST 2005


"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> 






More information about the Python-list mailing list