diff options
author | Georg Brandl <georg@python.org> | 2010-07-10 10:23:40 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-07-10 10:23:40 (GMT) |
commit | 93eb42e805524cd1375deab520d6f4828e0a4f53 (patch) | |
tree | b69cc37a998116bef8a9c3e5c92b453795a4fbda /Doc/library/struct.rst | |
parent | b382337ed672b06e1f48ff3ba0c3d0173cedb037 (diff) | |
download | cpython-93eb42e805524cd1375deab520d6f4828e0a4f53.zip cpython-93eb42e805524cd1375deab520d6f4828e0a4f53.tar.gz cpython-93eb42e805524cd1375deab520d6f4828e0a4f53.tar.bz2 |
Emphasize role of count for Pascal string.
Diffstat (limited to 'Doc/library/struct.rst')
-rw-r--r-- | Doc/library/struct.rst | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst index 4b1ba70..7878a54 100644 --- a/Doc/library/struct.rst +++ b/Doc/library/struct.rst @@ -259,18 +259,16 @@ then :exc:`struct.error` is raised. In 3.0, some of the integer formats wrapped out-of-range values and raised :exc:`DeprecationWarning` instead of :exc:`struct.error`. - The ``'p'`` format character encodes a "Pascal string", meaning a short -variable-length string stored in a fixed number of bytes. The count is the total -number of bytes stored. The first byte stored is the length of the string, or -255, whichever is smaller. The bytes of the string follow. If the string -passed in to :func:`pack` is too long (longer than the count minus 1), only the -leading count-1 bytes of the string are stored. If the string is shorter than -count-1, it is padded with null bytes so that exactly count bytes in all are -used. Note that for :func:`unpack`, the ``'p'`` format character consumes count -bytes, but that the string returned can never contain more than 255 bytes. - - +variable-length string stored in a *fixed number of bytes*, given by the count. +The first byte stored is the length of the string, or 255, whichever is +smaller. The bytes of the string follow. If the string passed in to +:func:`pack` is too long (longer than the count minus 1), only the leading +``count-1`` bytes of the string are stored. If the string is shorter than +``count-1``, it is padded with null bytes so that exactly count bytes in all +are used. Note that for :func:`unpack`, the ``'p'`` format character consumes +``count`` bytes, but that the string returned can never contain more than 255 +bytes. For the ``'?'`` format character, the return value is either :const:`True` or :const:`False`. When packing, the truth value of the argument object is used. |