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

MRAB python at mrabarnett.plus.com
Sun Dec 27 14:09:30 EST 2015


On 2015-12-27 17:16, Guido van Rossum wrote:
> On Sat, Dec 26, 2015 at 10:19 PM, Nick Coghlan <ncoghlan at gmail.com
> <mailto:ncoghlan at gmail.com>> wrote:
>
>     On 27 December 2015 at 07:05, Andrew Barnert via Python-ideas
>     <python-ideas at python.org <mailto: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.
>
>
> I really feel you all are overworrying and overthinking this. A downside
> to me is that <...> isn't clear about what the type of the object is.
> The use case here is not sophisticated users, it's beginners who have
> accidentally managed to create a recursive list or dict. They have most
> likely not even encountered Ellipsis objects yet. There's nothing
> clearer than the current notation to help them see that they've done
> something unusual.
>
We could always just use 4 dots instead.


More information about the Python-ideas mailing list