bitstring is a pure Python module designed to help make the creation, manipulation and analysis of binary data as simple and natural as possible.
BitStrings can be constructed from integers (big and little endian), hex, octal, binary, strings or files. They can be sliced, joined, reversed, inserted into, overwritten, etc. with simple functions or slice notation. They can also be read from, searched and replaced, and navigated in, similar to a file or stream.
Internally the data is efficiently stored as byte arrays, the module has been optimized for speed, and excellent code coverage is given by over 300 unit tests. It is available for Python 2.4 / 2.5 and for Python 2.6 / 3.x.
To get updates on new releases you can subscribe to the project on freshmeat.
NewsMarch 18th 2010: Version 1.3.0 for Python 2.6 and 3.x releasedFor details see the ReleaseNotes.
View the Documentation HereIt contains a walk-through of all the features and a complete reference section.
>>> a = BitString(bin='00101')
>>> b = BitString(a_file_object)
>>> c = BitString('0xff, 0b101, 0o65, uint:6=22')
>>> d = pack('intle:16, hex=a, 0b1', 100, a='0x34f')
>>> e = pack('>> c.delete(4, 12)See the Wiki and the user manual for more examples.
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.