> On 3 Nov 2019, at 16:50, Andrew Barnert <abarn...@yahoo.com> wrote:
> 
> 
>> 
>>> On Nov 3, 2019, at 16:07, Anders Hovmöller <bo...@killingar.net> wrote:
>>> 
>>>> On 3 Nov 2019, at 13:31, Andrew Barnert <abarn...@yahoo.com> wrote:
>>> 
>>> On Nov 3, 2019, at 13:01, Anders Hovmöller <bo...@killingar.net> wrote:
>>>> 
>>>> Well, the last part requires that print can coerce bytes to str, not 
>>>> strictly that it must do so via str(). repr() should return b'foo' but 
>>>> str() could have returned <bytes object at 0x6363737>.
>>> 
>>> That would be very confusing.
>> 
>> 
>> Why? Because you then say:
>> 
>>> When they differ, it’s always repr that returns something like <bytes 
>>> object at 0x6363737>, as object.__repr__ gives. The only time you get that 
>>> from str is on types without a __str__ method that fall back to __repr__.
>> 
>> And str of bytes deviate from this in that it returns what should be a repr, 
>> not a str.
> 
> It doesn’t deviate. When they differ, it’s always repr that returns the 
> angle-bracket format. When they don’t differ, they obviously don’t differ. 
> Since bytes doesn’t differ, it follows that rule just fine.
> 
> The rules are pretty simple: (1) __repr__ returns either something eval-able 
> if feasible or something angle-brackety if not; bytes follows this rule by 
> returning something eval-able. (2) __str__ returns either something more 
> human-readable if reasonable, or falls back to __repr__ if not; bytes follows 
> this by falling back to __repr__.
> 
> Your proposal is to make __str__ return something _less_ human-readable, and, 
> worse, something that looks like a repr. That would be confusing.

It's not a proposal though.  It's way too late to change this now. I'm just 
saying the situation for the switch wasn't ideal. I think we all agree on that 
but for different reasons ;)

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

Reply via email to