9 Sep
2021
9 Sep
'21
10:59 a.m.
On Wed, Sep 08, 2021 at 05:06:08PM -0000, Brandt Bucher wrote:
Steven D'Aprano wrote:
To me, it sounds like should be the opposite of int.from_bytes.
int.from_bytes(b'Hello world', 'little') 121404708502361365413651784 >>> bytes.from_int(121404708502361365413651784, 'little') # should return b'Hello world' If that's not the API being suggested, that's going to be confusing.
I'm a bit lost here... why are we convinced at all that we need a new way to do this? Hasn't this functionality already existed for years?
x = int.from_bytes(b"*", "little") x 42 x.to_bytes(1, "little") b'*'
TIL :-) How have I never noticed to_bytes until now? o_O -- Steve