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) *  |
Date: 2018-09-27 06:23 |
What is the rationale of this change? |
|
|
msg326525 - (view) |
Author: Karthikeyan Singaravelan (xtreak) *  |
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) *  |
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) *  |
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. |
|
|