• Home
  • Popular Downloads
  • Contact Us
  • Submit

Softpile

Free Downloads

Main Navigation
  • Home
  • Windows
  • Mac OS X
  • Business
  • Desktop
  • Development
  • Education
  • Games
  • Internet
  • Multimedia
  • Utilities
Home » Linux » python-bitstring

python-bitstring

October 11, 2009
Simple construction, analysis and modification of binary data.
Version: 1.0.1
License: MIT/X Consortium License
Operating System: Linux
Homepage: code.google.com
Developed by: Scott Griffiths
python-bitstring is a Python module for analysing, constructing and modifying binary data.

The underlying binary data can be interpreted as, or constructed from, hexadecimal, octal or binary strings, signed or unsigned integers, and signed or unsigned Exponential Golomb coded integers. It can also be used as and created from plain Python strings.

The module is provided with a comprehensive set of unit tests and has been tested with Python 2.4, 2.5 and 2.6.

Example usage:

Different interpretations, slicing and concatenation:

a = BitString(uint=5647, length=16)

print a.hex, a.bin, a.uint # 0x160f 0b0001011000001111 5647
print a[3:9].bin, a[3:9].int # 0b101100 -20
print (a[0:4] + '0xf').hex # 0x1f

Reading data sequentially. Note that the data would more usually come from a read() on a binary file.

b = BitString(data='x00x00x01xb3x16x01x20x4f')

start_code = b.readbytes(4).hex # 0x000001b3
width = b.readbits(12).uint # 352
height = b.readbits(12).uint # 288
flags = b.readbits(3).bin # 0b010

Searching, inserting and deleting:

c = BitString(bin='00010010010010001111') # c.hex == '0x1248f'

c.findbytealigned('0x48')
print c.readbyte() # 0x48
c.insert('0b0000') # c.hex == '0x12480f'
c.deletebits(bits=8, deletepos=4) # c.hex == '0x180f'
analysis data data analysis data modification python python library
Free Download 461K
0
  • Share on:

python-bitstring User Reviews

Sponsored

Categories

  • Linux

Related Downloads

dlib C++ Library
dlib C++ Library is a modern C++ library with a focus on portability and ...
pycdio
Python OO interface to libcdio (CD Input and Control library)
extprot
Compact, efficient, extensible binary serialization format
poker-eval
A C library to evaluate poker hands.
PyComicView
A Python library for displaying comic directories
Copyright © 1999-2017 Softpile Free Downloads
  • Contact Us
  • Submit
  • Privacy Policy
  • Disclaimer
  • Terms of Use