[Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?]
Guido van Rossum
guido at python.org
Tue Jan 7 21:49:47 CET 2014
On Tue, Jan 7, 2014 at 9:43 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> My vision for a bytestring type (more refined):
>
> - made up of single bytes in the range 0 - 255 (no unicode anywhere)
>
> - indexing returns a bytestring of length 1, not an integer (as bytes
> does)
>
> - `bytestring(7)` either fails, or returns 'bytestring('\x07')' not
> 'bytestring(0, 0, 0, 0, 0, 0, 0)'
It sounds like you are just unhappy with some of the behavior of the
bytes object. I agree that these two behaviors are suboptimal, but it
is just too late to change them, and it's not enough to add a new type
-- not by a long shot. The constructor behavior can be changed using a
custom factory function. The indexing behavior, unfortunately, needs
to be dealt with by changing b[i] into b[i:i+1] everywhere.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list