Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Chris Angelico
On Wed, Nov 22, 2017 at 9:49 AM, Nick Timkovich wrote: > On Tue, Nov 21, 2017 at 11:22 AM, Chris Barker > wrote: >> >> supposedly __repr__ is supposed to give an eval-able version -- which your >> proposal is. But the way you did your example

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Nick Timkovich
On Tue, Nov 21, 2017 at 11:22 AM, Chris Barker wrote: > supposedly __repr__ is supposed to give an eval-able version -- which your > proposal is. But the way you did your example indicates that: > > bytes((42, 43, 44, 45, 46)) > > would be an even better __repr__, if the

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Steven D'Aprano
On Tue, Nov 21, 2017 at 01:35:41PM -0200, Joao S. O. Bueno wrote: > On 21 November 2017 at 13:16, Steven D'Aprano wrote: > > I'd rather leave __str__ and __repr__ alone. Changing them will have > > huge backwards compatibility implications. I'd rather give bytes a > >

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Kirill Balunov
2017-11-21 20:22 GMT+03:00 Chris Barker wrote: > But the way you did your example indicates that: > > bytes((42, 43, 44, 45, 46)) > > would be an even better __repr__, if the goal is to make it clear and easy > that it is a "container of integers from 0 to 255" > > I've

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Chris Barker
On Tue, Nov 21, 2017 at 6:37 AM, Kirill Balunov wrote: > Currently, __repr__ and __str__ representation of bytes is the same. > Perhaps it is worth making them different, this will make it easier to > visually perceive them as a container of integers from 0 to 255, >

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Victor Stinner
Hi, While it may shock you, using bytes for "text" makes sense in some areas. Please read the Motivation of the PEP 461: https://www.python.org/dev/peps/pep-0461/#motivation Victor 2017-11-21 15:37 GMT+01:00 Kirill Balunov : > Currently, __repr__ and __str__

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Steven D'Aprano
On Tue, Nov 21, 2017 at 05:37:36PM +0300, Kirill Balunov wrote: > Currently, __repr__ and __str__ representation of bytes is the same. > Perhaps it is worth making them different, this will make it easier to > visually perceive them as a container of integers from 0 to 255, > instead of a mixture

[Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Kirill Balunov
Currently, __repr__ and __str__ representation of bytes is the same. Perhaps it is worth making them different, this will make it easier to visually perceive them as a container of integers from 0 to 255, instead of a mixture of printable and non-printable ascii characters. It is proposed: a)