code: def pack(self, namedstruct):
          '''
          Pack the struct and return the packed bytes.
          
          :param namedstruct: a NamedStruct of this type.
          
          :returns: packed bytes, only contains fields of definitions in this type, not the sub type and "extra" data.
          '''
          elements = []
          t = namedstruct._target
          for p in self.properties:
              v = t
              for sp in p[0]:
                  v = getattr(v, sp)
              if len(p) > 1:
                  elements.extend(v[0:p[1]])
              else:
                  elements.append(v)
          return self.struct.pack(*elementsf pack(self, namedstruct):
          '''
          Pack the struct and return the packed bytes.
          
          :param namedstruct: a NamedStruct of this type.
          
          :returns: packed bytes, only contains fields of definitions in this type, not the sub type and "extra" data.
          '''
          elements = []
          t = namedstruct._target
          for p in self.properties:
              v = t
              for sp in p[0]:
                  v = getattr(v, sp)
              if len(p) > 1:
                  elements.extend(v[0:p[1]])
              else:
                  elements.append(v)
          return self.struct.pack(*elements)
docs: Pack the struct and return the packed bytes.
          
          :param namedstruct: a NamedStruct of this type.
          
          :returns: packed bytes, only contains fields of definitions in this type, not the sub type and "extra" data.