<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Jul 7, 2015, at 22:53, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><span>One of the more opaque error messages new Python users can encounter</span><br><span>is a syntax error due to unmatched parentheses:</span><br><span></span><br><span>    File "/home/me/myfile.py", line 11</span><br><span>        data = func()</span><br><span>        ^</span><br><span>    SyntaxError: invalid syntax</span><br><span></span><br><span>While I have no idea how we could implement it, I'm wondering if that</span><br><span>might be clearer if the error message instead looked more like this:</span><br><span></span><br><span>    File "/home/me/myfile.py", line 11</span><br><span>        data = func()</span><br><span>        ^</span><br><span>    SyntaxError: invalid syntax (Unmatched '(' on line 10)</span><br><span></span><br><span>Or, similarly,</span><br><span></span><br><span>    SyntaxError: invalid syntax (Unmatched '[' on line 10)</span><br><span>    SyntaxError: invalid syntax (Unmatched '{' on line 10)</span><br><span></span><br><span>I'm not sure it would be feasible though - we generate syntax errors</span><br><span>from a range of locations where we don't have access to the original</span><br><span>token data any more :(</span><br></div></blockquote><div><br></div><div>Do we know that there's an unbalanced parens (or bracket or brace) even when we don't know where it is? I think this would still be sufficient:</div><div><br></div><div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">   File "/home/me/myfile.py", line 11<br>       data = func()<br>       ^<br>   SyntaxError: invalid syntax (Unmatched '(', possibly on a previous line)</span></font></div></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></div><div>Really, just telling people to look at a previous line for unmatched pairs is sufficient to solve the problem every time it comes up on #python, StackOverflow, etc.</div><div><br></div><div>(Of course this would take away a great opportunity to explain to novices why they might want to use a better editor than Notepad, something which can show them mismatched parens automatically.)</div><blockquote type="cite"><div><span></span></div></blockquote></body></html>