[Python-Dev] Better SyntaxError messages

Greg Ward gward@mems-exchange.org
Wed, 5 Jul 2000 18:33:53 -0400

On 05 July 2000, Ka-Ping Yee said:
> How about this set of messages, then:
>     SyntaxError: unexpected indent
>     SyntaxError: unexpected unindent

How about "did not expect indent" and "did not expect unindent" -- reads
a little easier to my eyes.

>     SyntaxError: expected indent
>     SyntaxError: expected unindent
>     SyntaxError: unindent did not match any outer indentation level
>     SyntaxError: inconsistent use of tabs and spaces in indentation
>     SyntaxError: too many levels of indentation


> Hmm.  For the record, the section of the reference manual about
> indentation talks about INDENT and DEDENT tokens.  In fact i don't
> think there's any mention of the word "unindent" in the Python
> documentation.  But outside of the Python docs, "unindent" is
> clearly a commonly used and understood term in general practice,
> much more so than "dedent".

I don't think too many newbies read the reference manual (or the parser
source, for that matter).  Stick to clear, simple, plain-English terms
in error messages, even if they are different from (not inconsistent
with!) what's in the formal docs.

Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange / CNRI                           voice: +1-703-262-5376
Reston, Virginia, USA                            fax: +1-703-262-5367