def __init__(self, data): if len(data) < self.get_size(): raise DDSException('Not a DDS file') items = struct.unpack(self.get_format(), data) for field, value in compat_izip_longest(self._fields, items, fillvalue=None): setattr(self, field[0], value)