[issue16580] Add examples to int.to_bytes and int.from_bytes

Serhiy Storchaka report at bugs.python.org
Sat May 25 23:39:18 CEST 2013


Serhiy Storchaka added the comment:

I don't call it the examples. Here is the examples:

>>> (1234).to_bytes(2, 'big')
b'\x04\xd2'
>>> (1234).to_bytes(2, 'little')
b'\xd2\x04'
>>> (-1234).to_bytes(2, 'big', signed=True)
b'\xfb.'
>>> int.from_bytes(b'\xde\xad\xbe\xef', 'big')
3735928559
>>> int.from_bytes(b'\xde\xad\xbe\xef', 'little')
4022250974
>>> int.from_bytes(b'\xde\xad\xbe\xef', 'big', signed=True)
-559038737

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16580>
_______________________________________


More information about the Python-bugs-list mailing list