There is nice one for java – MINA.
Once I’ve heard that there is something similar for python. But can’t remind.
EDIT:
to be more specific, I would like to have a tool which would help me to create a coded for some binary stream.
EDIT2:
I’d like to list solutions here (thanks Scott for related topics)
Listed in order i’d use it.
Have you tried the bitstring module? (Full disclosure: I wrote it).
It’s designed to make constructing and parsing binary data as simple as possible. Take a look at a few examples to see if it’s anything like you need.
This snippet does some parsing of a H.264 video file: