On Tue, Jun 01, 2021 at 05:48:34AM -0300, André Roberge wrote:
> Actually, the very first observation I made is that, if you try to assign a
> value to '...', the traceback includes the message:
>
> SyntaxError: cannot assign to Ellipsis
>
> which is clearly wrong.
It is not _clearly_ wrong. Ellipsis is the name of the `...` symbol.
Regardless of the state of the built-in name Ellipsis, whether it has
been shadowed or monkey-patched, the symbol is still called Ellipsis.
You would have to grossly misread or misinterpret the traceback:
... = 42
^
SyntaxError: cannot assign to Ellipsis
as referring to the *name* Ellipsis rather than the symbol as shown. So
I would say its not wrong at all: it is technically and pedantically
correct, which is the best kind of correct.
So it is not *wrong*, but it does require a moderately subtle
understanding of Python symbols, names, and values (objects).
One easy change would be to just drop the capital E and call it
"ellipsis" (without the quotes), or even "the ellipsis symbol". To my
mind, that makes it clear we're talking about the symbol, not the
builtin name.
I dislike these:
SyntaxError: cannot assign to '...'
SyntaxError: cannot assign to ...
I'm not assigning to the string '...'; the second one looks like the
error message has been partially elided. So both are just as problematic
as the error message we are trying to improve.
[...]
> the only inconsistency left would be a more minor one, that is of the repr
> of '...' stating that it is Ellipsis which can be incorrect if Ellipsis is
> bound to a different value.
And that I don't think we should bother changing. It is completely
normal for the names of certain classes, functions and other values to
refer to the original name rather than the shadowing name. Ellipsis is
just another one of them.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/MSWOPKBRPALBPNCJ76MVPEIYJG6AXPJC/
Code of Conduct: http://python.org/psf/codeofconduct/