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

Guido van Rossum guido at python.org
Sun Dec 27 15:41:15 EST 2015


On Sun, Dec 27, 2015 at 1:20 PM, Serhiy Storchaka <storchaka at gmail.com>
wrote:

> On 27.12.15 19:16, Guido van Rossum wrote:
>
>> 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.
>>
>
> My second alternative was to use full object.__repr__. E.g. <list object
> at 0xb7111498>.


The problem isn't that it's too long (though it is) but that it just poses
the question "why is this not using the regular [etc] notation?"


> Or, if this is considered too long, shorter form: <list>.


Same here.


> Or, as Georg suggested, use the word "recursive" for clearness:
> <recursive>. Or combine type name and the word "recursive":
> <recursive list>.
>

Sure, but I still am curious what problem you are really trying to solve.
The problem seems to be purely in your mind. You also seem to be taken the
guideline that the repr() of an object should be eval()-able way too
strictly. It is just a guideline to help class authors decide what their
repr() should look like if they don't have a better idea. And the guideline
encourages writing repr()s that are intuitive to readers. Beyond that
there's nothing of value -- it just reduces guesswork on both sides.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151227/7a8f0929/attachment.html>


More information about the Python-ideas mailing list