Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; 'resulting': 0.04; 'mrab': 0.05; 'subject:Python': 0.06; 'suppose': 0.07; 'ascii': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'subject: [': 0.09; '~ethan~': 0.09; 'sfxlen:2': 0.11; 'jan': 0.12; 'be:': 0.16; 'mapped': 0.16; 'non-ascii': 0.16; 'subject:ideas': 0.16; 'subject:type': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'subject:] ': 0.20; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'andrew': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'skip:b 30': 0.33; 'could': 0.34; 'introducing': 0.36; 'should': 0.36; 'subject:new': 0.38; 'to:addr :python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'length': 0.61; 'new': 0.61; 'range': 0.61; 'received:173': 0.61; 'low': 0.83; '2014,': 0.84 Date: Tue, 07 Jan 2014 10:38:40 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: [Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?] References: <52C9B39F.6060205@stoneleaf.us> <87fvp1idip.fsf@uwakimon.sk.tsukuba.ac.jp> <1389009153.31778.YahooMailNeo@web181001.mail.ne1.yahoo.com> <87bnzphs7j.fsf@uwakimon.sk.tsukuba.ac.jp> <20140107154401.GK29356@ando> <52CC45E4.7010400@mrabarnett.plus.com> In-Reply-To: <52CC45E4.7010400@mrabarnett.plus.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:45052 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 3 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= Cc: Python-Ideas X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389119910 news.xs4all.nl 2944 [2001:888:2000:d::a6]:36903 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63446 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 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~