code: def read_fmt(fmt, fp):
      
      fmt = str(">" + fmt)
      fmt_size = struct.calcsize(fmt)
      data = fp.read(fmt_size)
      assert len(data) == fmt_size, 'read=%d, expected=%d' % (
          len(data), fmt_size
      )
      return struct.unpack(fmt, data)
docs: Reads data from ``fp`` according to ``fmt``.