4.3.1 Struct Objects
The struct module also defines the following type:
-
Return a new Struct object which writes and reads binary data according to
the format string format. Creating a Struct object once and calling
its methods is more efficient than calling the struct functions
with the same format since the format string only needs to be compiled once.
New in version 2.5.
Compiled Struct objects support the following methods and attributes:
-
Identical to the pack() function, using the compiled format.
(
len(result) will equal self.size.)
pack_into( |
buffer, offset, v1, v2, ...) |
-
Identical to the pack_into() function, using the compiled format.
-
Identical to the unpack() function, using the compiled format.
(
len(string) must equal self.size).
unpack_from( |
buffer[,offset
= 0 ]) |
-
Identical to the unpack_from() function, using the compiled format.
(
len(buffer[offset:]) must be at least self.size).
- format
-
The format string used to construct this Struct object.
Release 2.5.2, documentation updated on 21st February, 2008.
See About this document... for information on suggesting changes.
|