[Python-Dev] Re: Repr: where to place the address and additional info?

2020-06-01 Thread Brett Cannon
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}>

I prefer the address at the rear. Chances are you care more about the details 
than the address, so put the more useful information earlier.

> 
> There are examples of both ways in the stdlib. I am going to add new 
> custom reprs [1] and need to know what pattern looks better.
> Also, is "object" mandatory after the type name?
>  <{typename} object {details} at {address:#x}>
>  <{typename} object at {address:#x} {details}>

I don't think it's mandatory. Whatever reads best.

-Brett

> 
> [1] https://bugs.python.org/issue24391
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OY7UZGXEU32ACL7HOPI7RLGCOJEMTF5K/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Repr: where to place the address and additional info?

2020-05-30 Thread Steven D'Aprano
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`:



versus for example:





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
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/5TAAAPIT2USDRL7HF6EUQEO4FMIDNPK4/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Repr: where to place the address and additional info?

2020-05-29 Thread Ivan Pozdeev via Python-Dev
If you are going to give details, you'd better use the "equivalent expression" kind of repr. As I explained earlier in the "Enum._convert 
should change __repr__", the angle brackets repr doesn't actually give any information that the user can rely upon except the type and the 
address.


On 29.05.2020 23:02, 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}>

There are examples of both ways in the stdlib. I am going to add new custom 
reprs [1] and need to know what pattern looks better.

Also, is "object" mandatory after the type name?

    <{typename} object {details} at {address:#x}>
    <{typename} object at {address:#x} {details}>

[1] https://bugs.python.org/issue24391
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ANF7LRGBQ2AWP2KUJKHVY3GGQRH6PDYD/
Code of Conduct: http://python.org/psf/codeofconduct/
--
Regards,
Ivan

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/2SK5LUEC6UZVFVCZF45W2BO7KPR2Y24Z/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Repr: where to place the address and additional info?

2020-05-29 Thread MRAB

On 2020-05-29 21:02, 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}>

There are examples of both ways in the stdlib. I am going to add new
custom reprs [1] and need to know what pattern looks better.

Also, is "object" mandatory after the type name?

  <{typename} object {details} at {address:#x}>
  <{typename} object at {address:#x} {details}>

[1] https://bugs.python.org/issue24391

FWIW, my preference is for the address at the end for reasons already 
stated in the issue.

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/JK2LVYUTO4VJHFERETLD2RJLNJJVARKB/
Code of Conduct: http://python.org/psf/codeofconduct/