summaryrefslogtreecommitdiff
path: root/Doc/library/struct.rst
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-06-12 16:30:53 +0000
committerMark Dickinson <dickinsm@gmail.com>2010-06-12 16:30:53 +0000
commitfdb99f1563501b9a64f38874105028a373e7bd04 (patch)
tree4dbbd85030229805c72832c10155f5463913a3f9 /Doc/library/struct.rst
parentaacfa95d2e650b10ef226261fd6f3d74ee781bb1 (diff)
downloadcpython-git-fdb99f1563501b9a64f38874105028a373e7bd04.tar.gz
More struct module docs and docstring tweaks.
Diffstat (limited to 'Doc/library/struct.rst')
-rw-r--r--Doc/library/struct.rst42
1 files changed, 21 insertions, 21 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index f1002a5ed7..2f48a77acf 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -38,38 +38,38 @@ The module defines the following exception and functions:
.. function:: pack(fmt, v1, v2, ...)
- Return a bytes containing the values ``v1, v2, ...`` packed according to the
- given format. The arguments must match the values required by the format
- exactly.
+ Return a bytes object containing the values *v1*, *v2*, ... packed according
+ to the format string *fmt*. The arguments must match the values required by
+ the format exactly.
.. function:: pack_into(fmt, buffer, offset, v1, v2, ...)
- Pack the values ``v1, v2, ...`` according to the given format, write the
- packed bytes into the writable *buffer* starting at *offset*. Note that the
- offset is a required argument.
+ Pack the values *v1*, *v2*, ... according to the format string *fmt* and
+ write the packed bytes into the writable buffer *buffer* starting at
+ position *offset*. Note that *offset* is a required argument.
-.. function:: unpack(fmt, bytes)
+.. function:: unpack(fmt, buffer)
- Unpack the bytes (presumably packed by ``pack(fmt, ...)``) according to the
- given format. The result is a tuple even if it contains exactly one item.
- The bytes must contain exactly the amount of data required by the format
- (``len(bytes)`` must equal ``calcsize(fmt)``).
+ Unpack from the buffer *buffer* (presumably packed by ``pack(fmt, ...)``)
+ according to the format string *fmt*. The result is a tuple even if it
+ contains exactly one item. The buffer must contain exactly the amount of
+ data required by the format (``len(bytes)`` must equal ``calcsize(fmt)``).
.. function:: unpack_from(fmt, buffer, offset=0)
- Unpack the *buffer* according to the given format. The result is a tuple even
- if it contains exactly one item. The *buffer* must contain at least the
- amount of data required by the format (``len(buffer[offset:])`` must be at
- least ``calcsize(fmt)``).
+ Unpack from *buffer* starting at position *offset*, according to the format
+ string *fmt*. The result is a tuple even if it contains exactly one
+ item. *buffer* must contain at least the amount of data required by the
+ format (``len(buffer[offset:])`` must be at least ``calcsize(fmt)``).
.. function:: calcsize(fmt)
- Return the size of the struct (and hence of the bytes) corresponding to the
- given format.
+ Return the size of the struct (and hence of the bytes object produced by
+ ``pack(fmt, ...)``) corresponding to the format string *fmt*.
.. _struct-format-strings:
@@ -358,10 +358,10 @@ The :mod:`struct` module also defines the following type:
Identical to the :func:`pack_into` function, using the compiled format.
- .. method:: unpack(bytes)
+ .. method:: unpack(buffer)
Identical to the :func:`unpack` function, using the compiled format.
- (``len(bytes)`` must equal :attr:`self.size`).
+ (``len(buffer)`` must equal :attr:`self.size`).
.. method:: unpack_from(buffer, offset=0)
@@ -376,6 +376,6 @@ The :mod:`struct` module also defines the following type:
.. attribute:: size
- The calculated size of the struct (and hence of the bytes) corresponding
- to :attr:`format`.
+ The calculated size of the struct (and hence of the bytes object produced
+ by the :meth:`pack` method) corresponding to :attr:`format`.