[Python-Dev] Add more SyntaxWarnings?

Guido van Rossum guido at python.org
Thu Jan 24 18:58:50 EST 2019


On Thu, Jan 24, 2019 at 3:45 PM Chris Barker - NOAA Federal <
chris.barker at noaa.gov> wrote:

> >. There's nothing mysterious about e.g. `TypeError: unsupported operand
> type(s) for +: 'int' and 'str'`, unlike the case of the two concatenated
> tuples. (Surely people get errors about int+str all the time, and they've
> never complained -- unlike the tuple tuple case.)
>
> Well, yes, that particular example is pretty clear. But as a rule, there
> are a LOT of errors that can be pretty mysterious to newbies.
>
> I would love to see Python become generally more informative with errors.
>
> In this case, you’d probably get a similar error, but it’s still nice to
> get it sooner, and if the hooks are in place, We could have others that are
> really helpful.
>

I doubt people are writing `42 + "abc"` by accident. They'll write `x + y`
and by accident the types won't match. So better error messages at runtime
would help. But I doubt we'll see much mileage out of the syntax checks.
And making things work different based on whether it's a literal or a
variable isn't very Pythonic.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20190124/5145fa93/attachment.html>


More information about the Python-Dev mailing list