[Python-Dev] SyntaxError/IndentationError/WhitespaceError

Skip Montanaro skip@mojam.com (Skip Montanaro)
Tue, 4 Jul 2000 23:57:19 -0500 (CDT)


Just back from the annual patriotic revelry...

Here are my thoughts on the various kinds of exceptions one might raise to
denote various problems with indentation.

SyntaxError - the most general form of parsing error

WhitespaceError - tells the user something's wrong with the way the
whitespace of the line parses - what -tt mode would raise

IndentationError - more specific than WhitespaceError, but indicates the
lines won't line up properly (without -tt mode) - what the parser would
raise for something like:

    try:
        1/0
	    1/0
    except ZeroDivisionError:
        pass

The distinction between WhitespaceError and IndentationError is likely to be
a bit subtle for newbies, so I wonder if it's worth the effort to
distinguish the two.

-- 
Skip Montanaro, skip@mojam.com, http://www.mojam.com/, http://www.musi-cal.com/
"To get what you want you must commit yourself for sometime" - fortune cookie