[Python-ideas] Should a single/double quote followed by a left parenthesis raise SyntaxError?
Skip Montanaro
skip.montanaro at gmail.com
Wed Jul 15 17:54:59 CEST 2015
On Wed, Jul 15, 2015 at 10:40 AM, Jacob Niehus <jacob.niehus at gmail.com> wrote:
>>>> '%s' ('abc')
>
> yields a TypeError.
>
> My question is whether this should be caught as a syntax error instead
> of a runtime error.
It would only partially solve the problem (I think) you are trying to
solve. Consider this syntactically valid case:
>>> s = "%s"
>>> s ("abc")
TypeError 'str' object is not callable
The TypeError tells you exactly what the problem is. A SyntaxError
would catch the case where you try to call a string literal, but not a
string object.
Skip
More information about the Python-ideas
mailing list