[Python-ideas] reprs of recursive datastructures.

Alexander Belopolsky alexander.belopolsky at gmail.com
Sun Sep 9 00:06:14 CEST 2012

On Sat, Sep 8, 2012 at 5:26 PM, MRAB <python at mrabarnett.plus.com> wrote:
>>     Note that in doctest displays, ellipsis has yet another meaning.  I
>>     agree that this is 3.4 material, and the solution should probably be
>>     something in <>.
>> Ok, I can live with <...>.
> Should we also guarantee that it'll never have any other meaning in
> Python so that this will never happen again?

I was probably not very clear about the problem of having ellipsis
appear as expected output in doctests.  The problem is that '...' has
a special meaning for doctests:

When specified, an ellipsis marker (...) in the expected output can
match any substring in the actual output. ...
""" http://docs.python.org/py3k/library/doctest.html#doctest.ELLIPSIS

This means that <...> will match any angle bracketed repr.  Note that
lists are not the only types affected by this issue.  Dicts, for
example, have the same problem:

>>> d = {}
>>> d[0] = d
>>> d
{0: {...}}
>>> eval('{0: {...}}')
{0: {Ellipsis}}

It is possible the other mutable container types are similarly
affected.  It looks like this problem requires some more though.

If we ever decide to allow non-ASCII characters in repr, my vote for
repr of recursive list will be



More information about the Python-ideas mailing list