struct.py 359 B

123456789101112131415161718
  1. from ustruct import *
  2. error = ValueError
  3. class Struct(object):
  4. def __init__(self, format):
  5. self.format = format
  6. self.size = calcsize(format)
  7. def pack(self, *x):
  8. return pack(self.format, *x)
  9. def unpack(self, buffer):
  10. return unpack(self.format, buffer)
  11. def unpack_from(self, buffer, offset=0):
  12. return unpack_from(self.format, buffer, offset)