code: def pack_types(types, args, major):
      
      if len(types) > 0:
          multiple = types[-1]._multiple
      else:
          multiple = False
  
      if len(types) < len(args) and not multiple:
          raise ValueError("Too many arguments to pack.")
  
      if len(args) < len(types):
          # this passes in None for missing args
          retvals = map(lambda ktype, arg: ktype.pack(arg, major=major),
                        types, args)
      else:
          retvals = [ktype.pack(arg, major=major)
                     for ktype, arg in zip(types, args)]
  
      if len(args) > len(types) and multiple:
          last_ktype = types[-1]
          for arg in args[len(types):]:
              retvals.append(last_ktype.pack(arg, major=major))
  
      return retvals
docs: Pack arguments according the the types list.
  
      Parameters
      ----------
      types : list of kattypes
          The types of the arguments (in order).
      args : list of objects
          The arguments to format.
      major : integer
          Major version of KATCP to use when packing types