[Python-ideas] reprs of recursive datastructures.
raymond.hettinger at gmail.com
Sun Sep 9 07:04:34 CEST 2012
On Sep 8, 2012, at 6:02 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> The thing I don't like is that the current display flat out lies about
> the sequence contents - it displays a terminal constant ("..."),
> rather than a clear marker that a recursive loop was detected.
It's more of an equivocation than a flat-out lie ;-)
It is an equivocation because "..." is legitimately used
for multiple purposes (in English text for "and so on ...",
in long established use in Python to denote recursive reprs,
in doctest as a placeholder for elided result text, and in
its newest role as the Ellipsis terminal constant).
It seems to me that the first three roles are well-established
and are reasonably consistent with one another. Further,
each of those roles an important task.
In contrast, the new role as a terminal constant for an
Ellipsis singleton is brand-new, not very important,
and doesn't even have a clear semantic role (what it is
"supposed" to mean?).
Changing the first three uses just so it won't conflict with the last
seems like the tail wagging the dog.
I agree Steven that this isn't a problem worth solving.
As Alexander pointed-out, the ... punctuation can be used in two
distinct ways inside doctests (as part of expected output or as
a placeholder for elided content). A consequence is that
there won't be a reliable automated way to convert existing
doctests for a new notation for recursive reprs.
ISTM that changes which break tests are worse than other
changes because the process of upgrading from one Python
version to the next is so heavily dependent getting existing tests
to pass. The tests are your safety net during upgrades -- breaking them
makes upgrading less palatable.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas