You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/index.rst
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,23 @@
4
4
5
5
`bitformat <https://github.com/scott-griffiths/bitformat/>`_ is a Python module for creating and parsing file formats, especially at the bit rather than byte level.
6
6
7
-
It is intended to complement the **bitstring** module, but is currently at a planning stage and is not yet recommended for use.
7
+
It is intended to complement the `bitstring <https://github.com/scott-griffiths/bitstring>`_ module, but is currently at a planning stage and is not yet recommended for use.
8
+
9
+
----
10
+
11
+
The `bitformat` module provides the ``Format`` class which is used to define how to create and parse binary formats. ::
12
+
13
+
from bitformat import Format, Dtype, Bits
14
+
15
+
f1 = Format(Bits('0xabc')) # A bit literal (12 bits long)
16
+
f2 = Format(Dtype('u5')) # A 5-bit unsigned integer
17
+
18
+
f3 = Format([f1, f2, f2]) # A format made of other formats
19
+
20
+
d = f3.pack(3, 10) # A Bits object packed with the values 3 and 10
21
+
f3.parse(d) # returns 3, 10
22
+
23
+
8
24
9
25
10
26
These docs are styled using the `Piccolo theme <https://github.com/piccolo-orm/piccolo_theme>`_.
0 commit comments