{
    "content": [
        {
            "type": "text",
            "text": "# _struct (pydoc)\n\n**Summary:** struct\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (29 lines)\n- **CLASSES** (5 lines) — 2 subsections\n  - class Struct (75 lines)\n  - class error (67 lines)\n- **FUNCTIONS** (1 lines) — 6 subsections\n  - calcsize (2 lines)\n  - iter_unpack (7 lines)\n  - pack (5 lines)\n  - pack_into (7 lines)\n  - unpack (6 lines)\n  - unpack_from (6 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\nstruct\n\n### DESCRIPTION\n\nFunctions to convert between Python values and C structs.\nPython bytes objects are used to hold the data representing the C struct\nand also as format strings (explained below) to describe the layout of data\nin the C struct.\n\nThe optional first format char indicates byte order, size and alignment:\n@: native order, size & alignment (default)\n=: native order, std. size & alignment\n<: little-endian, std. size & alignment\n>: big-endian, std. size & alignment\n!: same as >\n\nThe remaining chars indicate types of args and must match exactly;\nthese can be preceded by a decimal repeat count:\nx: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n?: Bool (requires C99; if not available, char is used instead)\nh:short; H:unsigned short; i:int; I:unsigned int;\nl:long; L:unsigned long; f:float; d:double; e:half-float.\nSpecial cases (preceding decimal count indicates length):\ns:string (array of char); p: pascal string (with count byte).\nSpecial cases (only available in native format):\nn:ssizet; N:sizet;\nP:an integer type that is wide enough to hold a pointer.\nSpecial case (not in native mode unless 'long long' in platform C):\nq:long long; Q:unsigned long long\nWhitespace between formats is ignored.\n\nThe variable struct.error is an exception raised on errors.\n\n### CLASSES\n\nbuiltins.Exception(builtins.BaseException)\nstruct.error\nbuiltins.object\nStruct\n\n#### class Struct\n\n|  Struct(fmt) --> compiled struct object\n|\n|  Methods defined here:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  sizeof(...)\n|      S.sizeof() -> size of S in memory, in bytes\n|\n|  iterunpack(self, buffer, /)\n|      Return an iterator yielding tuples.\n|\n|      Tuples are unpacked from the given bytes source, like a repeated\n|      invocation of unpackfrom().\n|\n|      Requires that the bytes length be a multiple of the struct size.\n|\n|  pack(...)\n|      S.pack(v1, v2, ...) -> bytes\n|\n|      Return a bytes object containing values v1, v2, ... packed according\n|      to the format string S.format.  See help(struct) for more on format\n|      strings.\n|\n|  packinto(...)\n|      S.packinto(buffer, offset, v1, v2, ...)\n|\n|      Pack the values v1, v2, ... according to the format string S.format\n|      and write the packed bytes into the writable buffer buf starting at\n|      offset.  Note that the offset is a required argument.  See\n|      help(struct) for more on format strings.\n|\n|  unpack(self, buffer, /)\n|      Return a tuple containing unpacked values.\n|\n|      Unpack according to the format string Struct.format. The buffer's size\n|      in bytes must be Struct.size.\n|\n|      See help(struct) for more on format strings.\n|\n|  unpackfrom(self, /, buffer, offset=0)\n|      Return a tuple containing unpacked values.\n|\n|      Values are unpacked according to the format string Struct.format.\n|\n|      The buffer's size in bytes, starting at position offset, must be\n|      at least Struct.size.\n|\n|      See help(struct) for more on format strings.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  format\n|      struct format string\n|\n|  size\n|      struct size in bytes\n\n#### class error\n\n|  Method resolution order:\n|      error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n\n### FUNCTIONS\n\n#### calcsize\n\nReturn size in bytes of the struct described by the format string.\n\n#### iter_unpack\n\nReturn an iterator yielding tuples unpacked from the given bytes.\n\nThe bytes are unpacked according to the format string, like\na repeated invocation of unpackfrom().\n\nRequires that the bytes length be a multiple of the format struct size.\n\n#### pack\n\npack(format, v1, v2, ...) -> bytes\n\nReturn a bytes object containing the values v1, v2, ... packed according\nto the format string.  See help(struct) for more on format strings.\n\n#### pack_into\n\npackinto(format, buffer, offset, v1, v2, ...)\n\nPack the values v1, v2, ... according to the format string and write\nthe packed bytes into the writable buffer buf starting at offset.  Note\nthat the offset is a required argument.  See help(struct) for more\non format strings.\n\n#### unpack\n\nReturn a tuple containing values unpacked according to the format string.\n\nThe buffer's size in bytes must be calcsize(format).\n\nSee help(struct) for more on format strings.\n\n#### unpack_from\n\nReturn a tuple containing values unpacked according to the format string.\n\nThe buffer's size, minus offset, must be at least calcsize(format).\n\nSee help(struct) for more on format strings.\n\n### FILE\n\n(built-in)\n\n"
        }
    ],
    "structuredContent": {
        "command": "_struct",
        "section": "",
        "mode": "pydoc",
        "summary": "struct",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 29,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 5,
                "subsections": [
                    {
                        "name": "class Struct",
                        "lines": 75
                    },
                    {
                        "name": "class error",
                        "lines": 67
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "calcsize",
                        "lines": 2
                    },
                    {
                        "name": "iter_unpack",
                        "lines": 7
                    },
                    {
                        "name": "pack",
                        "lines": 5
                    },
                    {
                        "name": "pack_into",
                        "lines": 7
                    },
                    {
                        "name": "unpack",
                        "lines": 6
                    },
                    {
                        "name": "unpack_from",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}