Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63446

Re: [Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?]

Date 2014-01-07 10:38 -0800
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: [Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?]
References (4 earlier) <1389009153.31778.YahooMailNeo@web181001.mail.ne1.yahoo.com> <87bnzphs7j.fsf@uwakimon.sk.tsukuba.ac.jp> <20140107154401.GK29356@ando> <FAE8F24A-C18A-4CC7-BE9D-06804BC99A3A@yahoo.com> <52CC45E4.7010400@mrabarnett.plus.com>
Newsgroups comp.lang.python
Message-ID <mailman.5148.1389119910.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 01/07/2014 10:22 AM, MRAB wrote:
> On 2014-01-07 17:46, Andrew Barnert wrote:
>> On Jan 7, 2014, at 7:44, Steven D'Aprano <steve@pearwood.info> wrote:
>>
> I was thinking about Ethan's suggestion of introducing a new bytestring
> class and a lot of these suggestions are what I thought the bytestring
> class could do.

>>>
>>> Suppose we take a pure-ASCII byte-string and decode it:
>>>
>>>    b'abcd'.decode('ascii-compatible')
>>>
> That would be:
>
>      bytestring(b'abcd')
>
> or even:
>
>      bytestring('abcd')
>
> [snip]
>>
>>> Suppose we take a byte-string with a non-ASCII byte:
>>>
>>>    b'abc\xFF'.decode('ascii-compatible')
>>>
> That would be:
>
>      bytestring(b'abc\xFF')
>
> Bytes outside the ASCII range would be mapped to Unicode low
> surrogates:
>
>      bytestring(b'abc\xFF') == bytestring('abc\uDCFF')

Not sure what you mean here.  The resulting bytes should be 'abc\xFF' and of length 4.

--
~Ethan~

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?] Ethan Furman <ethan@stoneleaf.us> - 2014-01-07 10:38 -0800

csiph-web