By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

How to get TabError?

P: n/a
Can someone provide a snippet which, when run, generates a TabError?

I can only seem to get SyntaxError and IndentationError.

Thanks,
M
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
When running with "-tt", you can get this error.

[jepler@sofa src]$ python -tt
Python 2.3.3 (#1, May 7 2004, 10:31:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
exec "def f():\n\ta\n b"

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 3
b
^
TabError: inconsistent use of tabs and spaces in indentation
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFCRt7EJd01MZaTXX0RAuXQAKCCI6hsv29qK9bNFZrk9d ayihCT7wCfSZMm
LosXa6miRGuwE5s4y470r3Y=
=y0vY
-----END PGP SIGNATURE-----

Jul 18 '05 #2

P: n/a
"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>

Jul 18 '05 #3

P: n/a
In article <ma*************************************@python.or g>,
"Fredrik Lundh" <fr*****@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
Jul 18 '05 #4

P: n/a
In article <ma*************************************@python.or g>,
"Fredrik Lundh" <fr*****@pythonware.com> wrote:
$ python -t test.py
test.py: inconsistent use of tabs and spaces in indentation
hello
goodbye


On more question. When using py_compile from with a script, is there any
way to force the -t flag?

M
Jul 18 '05 #5

P: n/a
"Mr. Magoo" wrote:
$ python -t test.py
test.py: inconsistent use of tabs and spaces in indentation
hello
goodbye


On more question. When using py_compile from with a script, is there any
way to force the -t flag?


if you want to check for tab problems from inside a script, use the
tabnanny module:

http://effbot.org/librarybook/tabnanny.htm

</F>

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.