
On Fri, May 29, 2020 at 11:02:56PM +0300, Serhiy Storchaka wrote:
The default repr of Python object is formatted using the following pattern:
<{typename} object at {address:#x}>
And many custom reprs use similar patterns, but add some additional type specific information. The type name first, followed by details and address. All is surrounded by angle quotes. The question is in what order to show address and other details? Should the address be at rear or in the middle?
<{typename} {details} at {address:#x}> <{typename} at {address:#x} {details}>
Personally, I prefer the look of the first.
Also, is "object" mandatory after the type name?
Nothing is mandatory since you can make the repr return anything useful. I dislike the use of "object" in the default repr. I wish it would use "instance" since that is more precise (classes are objects too). Admittedly classes are instances of `type` but unless talking about metaclasses people don't usually refer to classes as instances but they do refer to them as objects. Also it looks silly when the object is an instance of `object`: <object object at 0xb7c7f560> versus for example: <object instance at 0xb7c7f560> <map instance at 0xb79059ec> <zip instance at 0xb79059ec> Since there's no builtin type `instance` and is unlikely to ever be one, I think that "instance" is a better word to use. It's probably not worth changing existing classes but maybe you could start a trend for new classes to use "instance" instead :-) -- Steven