Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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:Python': 0.04; 'suppose': 0.05; 'bytes.': 0.07; 'type,': 0.07; 'python': 0.07; 'bytearray': 0.09; 'mutable': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'constructor.': 0.16; 'curiosity,': 0.16; 'feature?': 0.16; 'furman': 0.16; 'immutable': 0.16; 'traceback': 0.16; '(most': 0.16; 'bytes': 0.19; 'tue,': 0.20; 'header:In-Reply-To:1': 0.22; 'integer': 0.23; 'last):': 0.23; 'null': 0.23; 'parameters': 0.26; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'later': 0.26; 'object': 0.27; 'skip:b 20': 0.27; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.161': 0.29; 'list': 0.30; '17,': 0.31; 'typeerror:': 0.31; 'does': 0.31; 'anyone': 0.31; 'to:addr:python- list': 0.32; 'actually': 0.34; '"",': 0.35; 'assignment': 0.35; 'received:209.85': 0.37; 'element': 0.38; 'received:google.com': 0.38; 'so,': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'takes': 0.40; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; '12:47': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=zwz/E+cxG7yeT6XkXFeJIdSzu3d0rgpIYUuwwNcCR0Q=; b=Q5hAE2eSjS6YxG38V3ha95TnR55OWf8H3X5JT3P78LoNmRQPtYmkmVp/upOeiTtPP8 ZbT59zjlaH08PWE7HLJP+8ukeAtCQTK0OMErxxf2RLq6pxnIRyZTz4QFFgRYnXt+rKed YF1i7KrqfWXWzbePRmdVxzd2CO1wa263JhUNI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=vgvfmvEhQSaPkybJTm0++WyAJWAgf8ghFYwU7x6iaprIRwh3GiweOip326TPOggs3f /DEM9eLelr9IuW0nWv22GtDtGxBn1kN0dKJ0RRm3iuAMvvhn9M3bMOPfz7KWWL0CTVmr FP/nw+W5jq+PVCtt3x7zWbyYEDbc08n+GR7mw= MIME-Version: 1.0 In-Reply-To: <4DD2C2A5.3080403@stoneleaf.us> References: <4DD2C2A5.3080403@stoneleaf.us> From: Ian Kelly Date: Tue, 17 May 2011 13:20:32 -0600 Subject: Re: Python 3.x and bytes To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305660064 news.xs4all.nl 49175 [::ffff:82.94.164.166]:40422 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5598 On Tue, May 17, 2011 at 12:47 PM, Ethan Furman wrote: > In Python 3 one can say > > --> huh =3D bytes(5) > > Since the bytes type is actually a list of integers, I would have expecte= d > this to have huh being a bytestring with one element -- the integer 5. > =A0Actually, what you get is: > > --> huh > b'\x00\x00\x00\x00\x00' > > or five null bytes. =A0Note that this is an immutable type, so you cannot= go > in later and say > > --> huh[3] =3D 9 > Traceback (most recent call last): > =A0File "", line 1, in > TypeError: 'bytes' object does not support item assignment > > > So, out of curiosity, does anyone actually use this, um, feature? I suppose it's for interoperability with the mutable bytearray type, which takes the same parameters in the constructor.