Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62489 > unrolled thread
| Started by | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| First post | 2013-12-21 12:29 +0000 |
| Last post | 2013-12-21 13:13 +0000 |
| Articles | 2 — 2 participants |
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: bytearray inconsistencies? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-21 12:29 +0000
Re: bytearray inconsistencies? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-21 13:13 +0000
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-21 12:29 +0000 |
| Subject | Re: bytearray inconsistencies? |
| Message-ID | <mailman.4469.1387628971.18130.python-list@python.org> |
On 21/12/2013 01:58, Ned Batchelder wrote: > > If you have a zero, you can split on it with: > bytestring.split(bytes([0])), but that doesn't explain why find can take > a simple zero, and split has to take a bytestring with a zero in it. > Create a bytearray(range(256)) and partition it on 128. I'd expect to see the original effectively cut in half with 128 as the separator. You actually get the original with two empty bytearrays, which makes no sense to me at all. I also looked in test_bytes.py, read as far as "XXX This is a mess" and promptly gave up. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-12-21 13:13 +0000 |
| Message-ID | <52b59414$0$6599$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #62489 |
On Sat, 21 Dec 2013 12:29:14 +0000, Mark Lawrence wrote: > Create a bytearray(range(256)) and partition it on 128. I'd expect to > see the original effectively cut in half with 128 as the separator. You > actually get the original with two empty bytearrays, which makes no > sense to me at all. I reckon that is a bug. Consider this smaller example: py> ba = bytearray(range(8)) py> ba bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07') py> 3 in ba True py> ba.find(3) == ba.index(3) == ba.find(b'\x03') True py> ba.partition(b'\x03') (bytearray(b'\x00\x01\x02'), bytearray(b'\x03'), bytearray(b'\x04\x05\x06 \x07')) py> ba.partition(3) (bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07'), bytearray(b''), bytearray (b'')) -- Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web