def Pokearray(length):
# okay, I learned.
# It's not possible to use a custom base class
# in a ctypes.Structure field. Forget about it
@classmethod
def fromBytes(cls, data):
return cls(*data)
def asBytes(self):
return bytes(iter(self))
t = ctypes.c_uint8 * length
t.fromBytes = fromBytes
t.bytes = asBytes
return t
评论列表
文章目录