code: def pack(self):
          
          data = []
          for field in self.__fields__:
              (vtype, vlen) = self.__fields_types__[field]
              if vtype == 'char': # string
                  data.append(getattr(self, field))
              elif isinstance(vtype, CStructMeta):
                  num = int(vlen / vtype.size)
                  if num == 1: # single struct
                      v = getattr(self, field, vtype())
                      v = v.pack()
                      if sys.version_info >= (3, 0):
                          v = ([bytes([x]) for x in v])
                      data.extend(v)
                  else: # multiple struct
                      values = getattr(self, field, [])
                      for j in range(0, num):
                          try:
                              v = values[j]
                          except:
                              v = vtype()
                          v = v.pack()
                          if sys.version_info >= (3, 0):
                              v = ([bytes([x]) for x in v])
                          data.extend(v)
              elif vlen == 1:
                  data.append(getattr(self, field))
              else:
                  v = getattr(self, field)
                  v = v[:vlen] + [0] * (vlen - len(v))
                  data.extend(v)
          return struct.pack(self.__fmt__, *data)
docs: Pack the structure data into a string