This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Change Py_Ellipse __str__ behavior.
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, photofone, serhiy.storchaka, xtreak
Priority: normal Keywords: patch

Created on 2018-09-27 06:11 by photofone, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sliceobject.c photofone, 2018-09-27 06:11 modified sliceobject.c
Pull Requests
URL Status Linked Edit
PR 9596 closed photofone, 2018-09-27 06:14
Messages (8)
msg326522 - (view) Author: tom.r (photofone) * Date: 2018-09-27 06:11
Added ellipsis_str function to Objects/sliceobject.c such that str(Ellipsis)=='...'.
msg326524 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-27 06:23
What is the rationale of this change?
msg326525 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-27 06:45
Thanks for the PR but this seems to be backwards incompatible though I don't know if anyone depends on this and I am curious about the reason to change. Since this was added in e449af7da94 (1996) and I am not sure if this needs to be changed though it's up to Guido to take a call. There seems to be no tests for this in test suite that catches this change too.

$ python2.7
Python 2.7.14 (default, Mar 12 2018, 13:54:56)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> str(Ellipsis)
'Ellipsis'
>>> repr(Ellipsis)
'Ellipsis'

Thanks
msg326526 - (view) Author: tom.r (photofone) * Date: 2018-09-27 06:55
Frankly, because it bothered me that ``...`` evaluates to ``Ellipsis`` but that ``Ellipsis`` could never print as ``...``.
msg326527 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-27 07:06
Are you aware that changing just __str__ will not change the result of repr(), so that nested Ellipsis and Ellipsis in REPL will be still represented by name?

>>> print(...)
...
>>> print([...])
[Ellipsis]
>>> ...
Ellipsis

But changing also __repr__ will conflict with using "..." for representing recursive collections.

>>> a = []
>>> a.append(a)
>>> a
[[...]]
msg326530 - (view) Author: tom.r (photofone) * Date: 2018-09-27 07:19
Yes. I wanted to change just __str__ because the string value of an Ellipsis should be, well, an ellipsis. The __repr__ representation helps distinguish between recursion and an ellipsis object, so that's fine the way it is.
msg326564 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-09-27 14:25
I'm against this. The str() and repr() of Ellipsis are 'Ellipsis' for a reason: to remind the user that this is "just" an object, not a piece of special syntax.
msg326571 - (view) Author: tom.r (photofone) * Date: 2018-09-27 16:30
That's understandable. Thanks for considering it, closing the patch.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78996
2018-09-27 16:30:20photofonesetstatus: open -> closed

messages: + msg326571
stage: patch review -> resolved
2018-09-27 14:25:40gvanrossumsetmessages: + msg326564
2018-09-27 07:19:54photofonesetmessages: + msg326530
2018-09-27 07:06:47serhiy.storchakasetmessages: + msg326527
2018-09-27 06:55:56photofonesetmessages: + msg326526
2018-09-27 06:45:58xtreaksetmessages: + msg326525
2018-09-27 06:23:59serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg326524
2018-09-27 06:22:46serhiy.storchakasetnosy: + gvanrossum
2018-09-27 06:18:17xtreaksetnosy: + xtreak
2018-09-27 06:14:28photofonesetkeywords: + patch
stage: patch review
pull_requests: + pull_request8994
2018-09-27 06:11:36photofonecreate