[Python-ideas] Reporting unmatched parentheses in SyntaxError messages?

Florian Bruhin me at the-compiler.org
Wed Jul 8 08:09:20 CEST 2015


* Nick Coghlan <ncoghlan at gmail.com> [2015-07-08 15:53:44 +1000]:
> One of the more opaque error messages new Python users can encounter
> is a syntax error due to unmatched parentheses:
> 
>     File "/home/me/myfile.py", line 11
>         data = func()
>         ^
>     SyntaxError: invalid syntax
> 
> While I have no idea how we could implement it, I'm wondering if that
> might be clearer if the error message instead looked more like this:
> 
>     File "/home/me/myfile.py", line 11
>         data = func()
>         ^
>     SyntaxError: invalid syntax (Unmatched '(' on line 10)
> 
> [...]

I can't comment on the implementation - but I can confirm this comes
up a lot in the #python IRC channel. People usually paste that line
and ask what is wrong with it, and the answer usually is "look on the
previous line".

I can imagine having this error message instead would help people
understand what's going on, without having to *know* they should look
at the previous line when there's a SyntaxError which "makes no
sense".

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150708/27c1d40b/attachment-0001.sig>


More information about the Python-ideas mailing list