Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Jacco van Dorp
> I think this method is easy to miss, since people look at the docs for bytes > (e.g. using dir(bytes)). It might be worthwhile to either add a > `bytes.to_int(...)` method (better, IMHO), or to point to int.from_bytes on > the relevant part of the docs. > > Elazar A note in the docs about int.fr

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Elazar
I think this method is easy to miss, since people look at the docs for bytes (e.g. using dir(bytes)). It might be worthwhile to either add a `bytes.to_int(...)` method (better, IMHO), or to point to int.from_bytes on the relevant part of the docs. Elazar On Tue, May 1, 2018 at 5:09 PM Ken Hilton

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Ken Hilton
Whoops! Never seen that before. Nothing I searched up pointed me to it. Sorry for wasting your time! Ken; -- Sincerely, Ken; ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: htt

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Nick Coghlan
On 1 May 2018 at 21:30, Antoine Pitrou wrote: > > Hi Ken, > > On Tue, 1 May 2018 19:22:52 +0800 > Ken Hilton wrote: > > > > So I'm pretty sure everyone here is familiar with how the "bytes" object > > works in Python 3. It acts mostly like a string, with the exception that > > 0-dimensional subs

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Steven D'Aprano
On Tue, May 01, 2018 at 07:22:52PM +0800, Ken Hilton wrote: > The only way to get 493182234161465432041076 out of b'hovercraft' You seem to be using a bytes object as a base-256 number. Under what circumstances is this desirable? > in a single expression is as follows: What's so special about

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Antoine Pitrou
Hi Ken, On Tue, 1 May 2018 19:22:52 +0800 Ken Hilton wrote: > > So I'm pretty sure everyone here is familiar with how the "bytes" object > works in Python 3. It acts mostly like a string, with the exception that > 0-dimensional subscripting (var[idx]) returns an integer, not a bytes > object -