Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63444
| Date | 2014-01-07 09:02 -0800 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Bytes indexing returns an int |
| References | <52cbe15a$0$29993$c3e8da3$5496439d@news.astraweb.com> <CAF3XjbweCcbNE7Lb+JVXdThPj=jfqUChMEmB6CVOqxjh6TEvcA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5146.1389117017.18130.python-list@python.org> (permalink) |
On 01/07/2014 07:19 AM, David Robinow wrote: > > Python 3 grudgingly allows the "abomination" of byte strings (is that > what they're called?) No, that is *not* what they're called. If you find any place in the Python3 docs that does call them bytestrings please submit a bug report. On 01/07/2014 08:12 AM, Steven D'Aprano wrote: > People trying to port these libraries from 2.7 to 3 run into this problem, > and it causes them grief. This little difference between bytes in 2.7 and > bytes in 3.x is a point of friction which makes porting harder, and I'm > trying to understand the reason for it. If I recall correctly the way it was explained to me: bytes (lists, arrays, etc.) is a container, and when a container is indexed you get whatever the container held. If you slice the container you get a smaller container with the appropriate items. bytes (and bytearrays) are containers of ints, so indexing returns an int. One big problem with this whole scenario is that bytes then lies about what it contains. (And I hate lies! [1]) Anyway, I believe that's the rationale behind the change. -- ~Ethan~ [1] http://www.quickmeme.com/meme/3ts325
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bytes indexing returns an int Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-07 22:13 +1100
Re: Bytes indexing returns an int Ervin Hegedüs <airween@gmail.com> - 2014-01-07 12:53 +0100
Re: Bytes indexing returns an int Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-07 23:04 +1100
Re: Bytes indexing returns an int Terry Reedy <tjreedy@udel.edu> - 2014-01-07 09:29 -0500
Re: Bytes indexing returns an int David Robinow <drobinow@gmail.com> - 2014-01-07 10:19 -0500
Re: Bytes indexing returns an int Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-08 03:12 +1100
Re: Bytes indexing returns an int Serhiy Storchaka <storchaka@gmail.com> - 2014-01-07 21:48 +0200
Re: Bytes indexing returns an int Robin Becker <robin@reportlab.com> - 2014-01-08 11:05 +0000
Re: Bytes indexing returns an int wxjmfauth@gmail.com - 2014-01-08 08:08 -0800
Re: Bytes indexing returns an int Ned Batchelder <ned@nedbatchelder.com> - 2014-01-08 12:19 -0500
Re: Bytes indexing returns an int Piet van Oostrum <piet@vanoostrum.org> - 2014-01-09 18:05 +0100
Re: Bytes indexing returns an int Ethan Furman <ethan@stoneleaf.us> - 2014-01-09 09:28 -0800
Re: Bytes indexing returns an int Serhiy Storchaka <storchaka@gmail.com> - 2014-01-09 21:36 +0200
Re: Bytes indexing returns an int Michael Torrie <torriem@gmail.com> - 2014-01-08 10:25 -0700
Re: Bytes indexing returns an int David Robinow <drobinow@gmail.com> - 2014-01-07 10:23 -0500
Re: Bytes indexing returns an int Ethan Furman <ethan@stoneleaf.us> - 2014-01-07 09:02 -0800
Re: Bytes indexing returns an int Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-08 11:15 +1100
Re: Bytes indexing returns an int Chris Angelico <rosuav@gmail.com> - 2014-01-08 11:30 +1100
Re: Bytes indexing returns an int Grant Edwards <invalid@invalid.invalid> - 2014-01-08 02:34 +0000
Re: Bytes indexing returns an int Chris Angelico <rosuav@gmail.com> - 2014-01-08 14:46 +1100
Re: Bytes indexing returns an int Ethan Furman <ethan@stoneleaf.us> - 2014-01-07 16:37 -0800
csiph-web