[Python-ideas] Fwd: Re: Unambiguous repr for recursive objects

Nick Coghlan ncoghlan at gmail.com
Sun Dec 27 00:19:46 EST 2015


On 27 December 2015 at 07:05, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> At any rate, I think what people are actually worried about here is not the theoretical chance that such a regression might have happened 5 years ago, but the more practical fact that 3.x might be misleading to human beings in cases where 2.x wasn't. For example, if you mostly do 3.x NumPy stuff, you're used to passing ellipses around, and maybe even storing them in index arrays, but you rarely if ever see a circular list. So, when you see, say, `[[1], [2], [...]]` on the REPL, you may misinterpret it as meaning something different from what it does.

Right, this is the reason I think it's reasonable to suggesting
changing the recursive repr - the current form is one that *humans*
that have only learned Python 3 are likely to misinterpret, since the
fact that "repr(...)"produces "Ellipsis" rather than "..." is itself a
quirk originating in the fact that "..." is restricted to subscripts
in Python 2.

I don't think it's a major problem (as recursive container
representations aren't something that comes up every day), but
switching to "<...>" does have the advantage of allowing for a
consistent recursive reference representation across all container
types, regardless of whether they have native syntax or not.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list