Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5598 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2011-05-17 13:20 -0600 |
| Last post | 2011-05-17 13:20 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python 3.x and bytes Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-17 13:20 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-05-17 13:20 -0600 |
| Subject | Re: Python 3.x and bytes |
| Message-ID | <mailman.1697.1305660064.9059.python-list@python.org> |
On Tue, May 17, 2011 at 12:47 PM, Ethan Furman <ethan@stoneleaf.us> wrote: > In Python 3 one can say > > --> huh = bytes(5) > > Since the bytes type is actually a list of integers, I would have expected > this to have huh being a bytestring with one element -- the integer 5. > Actually, what you get is: > > --> huh > b'\x00\x00\x00\x00\x00' > > or five null bytes. Note that this is an immutable type, so you cannot go > in later and say > > --> huh[3] = 9 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > 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.
Back to top | Article view | comp.lang.python
csiph-web