261
261
.. versionadded:: 2.5
263
Compiled Struct objects support the following methods and attributes:
266
.. method:: Struct.pack(v1, v2, ...)
268
Identical to the :func:`pack` function, using the compiled format.
269
(``len(result)`` will equal :attr:`self.size`.)
272
.. method:: Struct.pack_into(buffer, offset, v1, v2, ...)
274
Identical to the :func:`pack_into` function, using the compiled format.
277
.. method:: Struct.unpack(string)
279
Identical to the :func:`unpack` function, using the compiled format.
280
(``len(string)`` must equal :attr:`self.size`).
283
.. method:: Struct.unpack_from(buffer[, offset=0])
285
Identical to the :func:`unpack_from` function, using the compiled format.
286
(``len(buffer[offset:])`` must be at least :attr:`self.size`).
289
.. attribute:: Struct.format
291
The format string used to construct this Struct object.
293
.. attribute:: Struct.size
295
The calculated size of the struct (and hence of the string) corresponding
263
Compiled Struct objects support the following methods and attributes:
266
.. method:: pack(v1, v2, ...)
268
Identical to the :func:`pack` function, using the compiled format.
269
(``len(result)`` will equal :attr:`self.size`.)
272
.. method:: pack_into(buffer, offset, v1, v2, ...)
274
Identical to the :func:`pack_into` function, using the compiled format.
277
.. method:: unpack(string)
279
Identical to the :func:`unpack` function, using the compiled format.
280
(``len(string)`` must equal :attr:`self.size`).
283
.. method:: unpack_from(buffer[, offset=0])
285
Identical to the :func:`unpack_from` function, using the compiled format.
286
(``len(buffer[offset:])`` must be at least :attr:`self.size`).
289
.. attribute:: format
291
The format string used to construct this Struct object.
295
The calculated size of the struct (and hence of the string) corresponding