[Python-ideas] Enabling / disabling optional type hinting

Guido van Rossum guido at python.org
Sat Mar 23 19:20:40 EDT 2019

On Sat, Mar 23, 2019 at 2:43 PM Andre Roberge <andre.roberge at gmail.com>

> My original message was referring to someone writing ":" instead of "=" by
> mistake -- nothing to do with the walrus assignment, but rather using the
> same notation to assign a value to a key as they would when defining a dict.

OK, I read your Original Post for this thread, about accidentally writing
`d["answer"]: 42` instead of `d["answer"] = 42`.

My reaction is that this was a user mistake of the same kind as
accidentally writing `x + 1` instead of `x += 1`. That's just going to
happen, very occasionally. (Though why? The ':' and '=' keys are not that
close together.) Read your code carefully, or in an extreme case step
through it in a debugger, and you'll notice the mistake.

It's not a reason to pick on that particular syntax, and not much of a
reason to try and introduce a mechanism to disable type hints. Sorry.

PS. This particular syntax was introduced by PEP 526, and introduced in
Python 3.6.

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190323/4e9dd1da/attachment.html>

More information about the Python-ideas mailing list