Fixing typo: >>> s = str >>> str = int >>> str <class 'int'> >>> s <class 'str'>
On Mon, 2021-05-31 at 08:31 -0700, Paul Bryan wrote: > Because ... is still bound to the original Ellipsis. Just as "s" > below will remain bound to the original str. > > >>> s = str > >>> str = int > >>> int > <class 'int'> > >>> s > <class 'str'> > > Paul > > On Mon, 2021-05-31 at 16:16 +0100, MRAB wrote: > > On 2021-05-31 15:55, Paul Bryan wrote: > > > If you're proposing prevention of monkey patching Ellipsis, I > > > think > > > you'll have to go all-in on all builtins. > > > > > > For example: > > > > > > > > > str = int > > > > > > > > > str > > > > > > <class 'int'> > > > > > > > > > str == int > > > > > > True > > > > > > > > If you rebind str to int, the repr of str will say <class 'int'>, > > so you > > can tell that something's happened, but the repr of ... is always > > 'Ellipsis', even though you've rebound Ellipsis. > > > > > > > > On Mon, 2021-05-31 at 11:37 -0300, André Roberge wrote: > > > > In Python `...` is referred to as `Ellipsis` and cannot be > > > > assigned to. > > > > Yet, one can assign any value to the name `Ellipsis`. > > > > > > > > Consider the following: > > > > > > > > ``` > > > > > > > ... > > > > Ellipsis > > > > > > > ... == Ellipsis > > > > True > > > > > > > Ellipsis > > > > Ellipsis > > > > > > > Ellipsis = 3 > > > > > > > Ellipsis > > > > 3 > > > > > > > ... = 4 > > > > File "<stdin>", line 1 > > > > ... = 4 > > > > ^ > > > > SyntaxError: cannot assign to Ellipsis > > > > > > > # But I just did assign a new value to the name > > > > > > > Ellipsis above. > > > > > > > Ellipsis > > > > 3 > > > > > > > ... > > > > Ellipsis > > > > > > > ... == Ellipsis > > > > False > > > > ``` > > > > > > > > For consistency, `Ellipsis` (the name) should **always** refer > > > > to the > > > > same object that `...` refers to, so that both could not be > > > > assigned a > > > > new value. > > > > > > _______________________________________________ > > Python-ideas mailing list -- python-ideas@python.org > > To unsubscribe send an email to python-ideas-le...@python.org > > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > > Message archived at > > https://mail.python.org/archives/list/python-ideas@python.org/message/NE2FAW3XDFYUIMILV4BC2XT6VKLC4P6V/ > > Code of Conduct: http://python.org/psf/codeofconduct/ > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/UTNK34FPS7OHK5X3OLCYXWFZ4HNUKJDI/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/P4U32JFIIV3FSD4DTPO7XBDIUUIEPYTX/ Code of Conduct: http://python.org/psf/codeofconduct/