bitstring is a pure Python module that makes the creation, manipulation and analysis of binary data as simple and natural as possible.

# Features

- Supports Python 2.7 and Python 3.

- Rich API - chances are that whatever you want to do there’s a simple and elegant way of doing it.

- Bit level slicing, joining, searching, replacing and more.

- Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.

- Powerful binary packing and unpacking functions.

- Read from and interpret bitstrings as streams of binary data.

# Installation and Download

To install just `pip install bitstring`.

To download the module, as well as for defect reports, enhancement requests and Git repository browsing go to the project’s home on GitHub: http://scott-griffiths.github.io/bitstring/

# Documentation

The manual provides an introduction to the module and details most its capabilities.

The reference section has a complete list of all the classes, methods, attributes and functions of the `bitstring` module, together with short examples for many items.

- User Manual
  - Walkthrough
  - Introduction
  - Creation
  - Packing
  - Interpreting Bitstrings
  - Slicing, Dicing and Splicing
  - Reading, Parsing and Unpacking
  - Miscellany
- Reference
  - Quick Reference
  - The bitstring module
  - The Bits class
  - The BitArray class
  - The ConstBitStream class
  - The BitStream class
  - Functions
  - Exceptions
- Appendices
  - Examples
  - Exponential-Golomb Codes
  - Optimisation Techniques
  - Release Notes

The manual is also available as a PDF:

- Latest manual (PDF)

# Index and search

- Index

- Search Page

# Credits

Written by Scott Griffiths <dr.scottgriffiths@gmail.com>. If you have any questions, suggestions or criticisms (about this module!) then please email me. Also if you use bitstring in your own project then I’d be interested to hear how it’s being used.