Skip to content

Monthly Archives: December 2013

reading binary structures with python

06-Dec-13

Last week, I wanted to parse some Mach-O files with Python.  “Oh sure,” you think, “just use the struct module and this will be a breeze.”  I have, however, tried to do that: class MyBinaryBlob: def __init__(self, buf, offset): self.f1, self.f2 = struct.unpack_from(“BB”, buf, offset) and such an approach involves a great deal of copy-and-pasted […]