I am writing a huffman implementation in Python as a learning exercise. I have got to the point of writing out my variable length huffman codes to a buffer (or file). Only
I'm perhaps a little late to the party, but there is this bitstream library:
https://pypi.python.org/pypi/bitstream/2.0.3