I'm pleased to announce the release of version 2.0 of the bitstring module.
What is it? ----------- bitstring helps to make creating, manipulating and deconstructing binary data as easy as possible. It allows arbitrary (and very large) bit patterns to be used without worrying about bit shifting and masking operations. The comprehensive API covers packing, reading, searching, replacing and slicing as well as bit setting and checking, a host of different binary interpretations and all the standard bit-wise operators. The module is pure Python and is available for Python 2.6 and later, including Python 3. What's new in version 2? ------------------------ The main change is a more powerful and streamlined API. Too much to go into here (see the release notes), but here are some simple examples: >>> s = BitString('0x000001b3') # create a 32-bit bitstring from hexadecimal >>> s += 'uint:12=352, uint:12=288' # append two 12-bit integers >>> s += bitstring.pack('<2f, 0b1, <h', 0.1, 3.7, 44) # pack more values >>> s.unpack('hex:32, 2*uint:12, <2f, bool, <h') # unpack it all ['0x000001b3', 352, 288, 0.10000000149011612, 3.700000047683716, True, 44] >>> s.tobytes() # convert to bytes b'\x00\x00\x01\xb3\x16\x01 \xcd\xcc\xcc=\xcd\x...@\x96\x00\x00' >>> t = s[32:41]. # slicing >>> t.bin # the binary interpretation '0b000101100' >>> list(t.findall('0b10')) # finding bit patterns [3, 6] Where can I find out more? -------------------------- The project's homepage is at http://python-bitstring.googlecode.com/ Documentation is hosted at http://packages.python.org/bitstring/ Release note for all versions: http://code.google.com/p/python-bitstring/wiki/ReleaseNotes -- Thanks, Scott Griffiths -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/