I agree with Guido. Yes, there are sequences of symbols that used to be
syntax errors but that now have some meaning in Python. The type annotation
colon is one of them. There are moderately many other constructs this can
be said of.

I can vaguely imagine accidentally using a colon rather than an equal sign
because the colon is similar to an assignment in a dict display. I don't
think anyone would do that as a slip of the finger, but more as a brain
glitch.

However, this feels like a very uncommon hazard, and just one among dozens
of similar ones. I don't think anything should be "fixed" at a language
level.

On Sat, Mar 23, 2019, 7:21 PM Guido van Rossum <gu...@python.org> wrote:

> On Sat, Mar 23, 2019 at 2:43 PM Andre Roberge <andre.robe...@gmail.com>
> wrote:
>
>> 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)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to