all Python 3Exceptionsexception
TabError
built-in exceptions
Inconsistent mixing of tabs and spaces in indentation (a subclass of IndentationError).
Syntax
raise TabError
This is a parse-time error, not a runtime one: the interpreter chokes before a single line of the file executes, so wrapping the offending spot in try/except inside that same file cannot help. The fix lives in your editor, not in your code: turn on visible whitespace and keep one indentation style throughout the file — four spaces per level, as PEP 8 recommends.
Examples
try:
raise TabError
except TabError as e:
print(type(e).__name__) # → TabError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy