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

Terry Reedy tjreedy at udel.edu
Thu Jul 9 22:10:02 CEST 2015


On 7/9/2015 7:58 AM, Nick Coghlan wrote:

[... message might have been]
>      File "/home/me/myfile.py", line 11
>          data = func()
>          ^
>      SyntaxError: expected "except" or "finally"

The opposite problem is a closer without an opener.

 >>> ]
SyntaxError: invalid syntax
 >>> except KeyError:
	
SyntaxError: invalid syntax

In both cases, "unexpected '{}'.format(obj) would be better, even 
without given the missing opener.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list