Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Dec 12, 2015
1 parent 82f89a6 commit 3987539
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ wrapping the result in a named tuple:
3
An example of packing/unpacking a unsinged integer, a signed integer,
a float and a bytearray:
a float, a boolean and a bytearray:

.. code-block:: python
>>> from bitstruct import *
>>> pack('u5s5f32b13', 1, -1, 3.75, bytearray(b'\xff\xff'))
bytearray(b'\x0f\xd0\x1c\x00\x00?\xfe')
>>> unpack('u5s5f32b13', bytearray(b'\x0f\xd0\x1c\x00\x00?\xfe'))
(1, -1, 3.75, bytearray(b'\xff\xf8'))
>>> calcsize('u5s5f32b13')
55
>>> pack('u5s5f32b1r13', 1, -1, 3.75, True, bytearray(b'\xff\xff'))
bytearray(b'\x0f\xd0\x1c\x00\x00?\xff')
>>> unpack('u5s5f32b1r13', bytearray(b'\x0f\xd0\x1c\x00\x00?\xff'))
(1, -1, 3.75, True, bytearray(b'\xff\xf8'))
>>> calcsize('u5s5f32b1r13')
56
An example of unpacking values from a hexstring and a binary file:

.. code-block:: python
>>> from bitstruct import *
>>> from binascii import *
>>> unpack('s17s13b24', bytearray(unhexlify('0123456789abcdef')))
>>> unpack('s17s13r24', bytearray(unhexlify('0123456789abcdef')))
(582, -3751, bytearray(b'\xe2j\xf3'))
>>> with open("test.bin", "rb") as fin:
... unpack('s17s13b24', bytearray(fin.read(8)))
... unpack('s17s13r24', bytearray(fin.read(8)))
...
...
(582, -3751, bytearray(b'\xe2j\xf3'))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='bitstruct',
version='2.0.0',
version='2.0.1',
description=('This module performs conversions between Python values '
'and C bit field structs represented as Python '
'bytearrays.'),
Expand Down

0 comments on commit 3987539

Please sign in to comment.