On 07/11/2018 05:22, jlada...@itu.edu wrote:
> On Tuesday, November 6, 2018 at 7:19:09 PM UTC-8, Terry Reedy wrote:
>> On 11/6/2018 9:30 PM, j...y@it.u wrote:
>>
>>> b = i.to_bytes(1, "big")
>>>
>>> Is there another function which provides a more logical interface to this
>>> straightforward task?
On Tuesday, November 6, 2018 at 7:19:09 PM UTC-8, Terry Reedy wrote:
> On 11/6/2018 9:30 PM, j...y@it.u wrote:
>
> > b = i.to_bytes(1, "big")
> >
> >Is there another function which provides a more logical interface to this
> >straightforward task?
>
> Yes
> >>> 33 .to_bytes(1, 'big')
> b'!'
>
On 11/6/2018 9:30 PM, jlada...@itu.edu wrote:
b = i.to_bytes(1, "big")
Is there another function which provides a more logical interface to this
straightforward task?
Yes
>>> 33 .to_bytes(1, 'big')
b'!'
>>> bytes((33,))
b'!'
See >>> bytes( # in IDLE or >>> help(bytes)
--
Terry Jan Reedy
On 11/6/2018 9:30 PM, jlada...@itu.edu wrote:
I'm using Python 3.6. I have a need to convert several small integers into
single bytes. As far as I can tell from reading through the Python docs, the
correct way to accomplish this task is:
b = i.to_bytes(1, "big")
This seems to work, but I fi
I'm using Python 3.6. I have a need to convert several small integers into
single bytes. As far as I can tell from reading through the Python docs, the
correct way to accomplish this task is:
b = i.to_bytes(1, "big")
This seems to work, but I find it cumbersome. I have to supply the byteorde