Best way to convert sequence of bytes to long integer
Mark Dickinson
dickinsm at gmail.com
Wed Jan 20 09:18:55 EST 2010
On Jan 20, 7:36 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> I have a byte string (Python 2.x string), e.g.:
>
> s = "g%$f yg\n1\05"
> assert len(s) == 10
>
> I wish to convert it to a long integer, treating it as base-256.
By the way, are you willing to divulge what you're using this
functionality for? When trying to hack out the API for int.to_bytes
and int.from_bytes on the mailing list and bug tracker, some of the
discussion about use-cases seemed a little too much like guesswork;
I'd be curious to find out about real-life use-cases.
Mark
More information about the Python-list
mailing list