@@ -111,7 +111,7 @@ Format Strings
111111--------------
112112
113113Format strings describe the data layout when
114- packing and unpacking data. They are built up from :ref: `format characters<format-characters > `,
114+ packing and unpacking data. They are built up from :ref: `type codes<type-codes > `,
115115which specify the type of data being packed/unpacked. In addition,
116116special characters control the :ref: `byte order, size and alignment<struct-alignment> `.
117117Each format string consists of an optional prefix character which
@@ -183,8 +183,8 @@ Use :data:`sys.byteorder` to check the endianness of your system.
183183Native size and alignment are determined using the C compiler's
184184``sizeof `` expression. This is always combined with native byte order.
185185
186- Standard size depends only on the format character ; see the table in
187- the :ref: `format-characters ` section.
186+ Standard size depends only on the type code ; see the table in
187+ the :ref: `type-codes ` section.
188188
189189Note the difference between ``'@' `` and ``'=' ``: both use native byte order, but
190190the size and alignment of the latter is standardized.
@@ -208,12 +208,12 @@ Notes:
208208 count of zero. See :ref: `struct-examples `.
209209
210210
211- .. _ format-characters :
211+ .. _ type-codes :
212212
213- Format Characters
214- ^^^^^^^^^^^^^^^^^
213+ Type Codes
214+ ^^^^^^^^^^
215215
216- Format characters have the following meaning; the conversion between C and
216+ Type codes (or format codes) have the following meaning; the conversion between C and
217217Python values should be obvious given their types. The 'Standard size' column
218218refers to the size of the packed value in bytes when using standard size; that
219219is, when the format string starts with one of ``'<' ``, ``'>' ``, ``'!' `` or
@@ -324,7 +324,7 @@ Notes:
324324 format used by the platform.
325325
326326(5)
327- The ``'P' `` format character is only available for the native byte ordering
327+ The ``'P' `` type code is only available for the native byte ordering
328328 (selected as the default or with the ``'@' `` byte order character). The byte
329329 order character ``'=' `` chooses to use little- or big-endian ordering based
330330 on the host system. The struct module does not interpret this as native
@@ -346,22 +346,22 @@ Notes:
346346 When packing, ``'x' `` inserts one NUL byte.
347347
348348(8)
349- The ``'p' `` format character encodes a "Pascal string", meaning a short
349+ The ``'p' `` type code encodes a "Pascal string", meaning a short
350350 variable-length string stored in a *fixed number of bytes *, given by the count.
351351 The first byte stored is the length of the string, or 255, whichever is
352352 smaller. The bytes of the string follow. If the byte string passed in to
353353 :func: `pack ` is too long (longer than the count minus 1), only the leading
354354 ``count-1 `` bytes of the string are stored. If the byte string is shorter than
355355 ``count-1 ``, it is padded with null bytes so that exactly count bytes in all
356- are used. Note that for :func: `unpack `, the ``'p' `` format character consumes
356+ are used. Note that for :func: `unpack `, the ``'p' `` type code consumes
357357 ``count `` bytes, but that the :class: `!bytes ` object returned can never contain more than 255
358358 bytes.
359359 When packing, arguments of types :class: `bytes ` and :class: `bytearray `
360360 are accepted.
361361
362362(9)
363- For the ``'s' `` format character , the count is interpreted as the length of the
364- byte string, not a repeat count like for the other format characters ; for example,
363+ For the ``'s' `` type code , the count is interpreted as the length of the
364+ byte string, not a repeat count like for the other type codes ; for example,
365365 ``'10s' `` means a single 10-byte string mapping to or from a single
366366 Python byte string, while ``'10c' `` means 10
367367 separate one byte character elements (e.g., ``cccccccccc ``) mapping
@@ -376,7 +376,7 @@ Notes:
376376 are accepted.
377377
378378(10)
379- For the ``'F' `` and ``'D' `` format characters , the packed representation uses
379+ For the ``'F' `` and ``'D' `` type codes , the packed representation uses
380380 the IEEE 754 binary32 and binary64 format for components of the complex
381381 number, regardless of the floating-point format used by the platform.
382382 Note that complex types (``F ``/``Zf `` and ``D ``/``Zd ``) are available unconditionally,
@@ -385,7 +385,7 @@ Notes:
385385 two-element C array containing, respectively, the real and imaginary parts.
386386
387387
388- A format character may be preceded by an integral repeat count. For example,
388+ A type code may be preceded by an integral repeat count. For example,
389389the format string ``'4h' `` means exactly the same as ``'hhhh' ``.
390390
391391Whitespace characters between formats are ignored; a count and its format must
@@ -402,7 +402,7 @@ then :exc:`struct.error` is raised.
402402
403403.. index :: single: ? (question mark); in struct format strings
404404
405- For the ``'?' `` format character , the return value is either :const: `True ` or
405+ For the ``'?' `` type code , the return value is either :const: `True ` or
406406:const: `False `. When packing, the truth value of the argument object is used.
407407Either 0 or 1 in the native or standard bool representation will be packed, and
408408any non-zero value will be ``True `` when unpacking.
@@ -457,7 +457,7 @@ the result in a named tuple::
457457 >>> Student._make(unpack('<10sHHb', record))
458458 Student(name=b'raymond ', serialnum=4658, school=264, gradelevel=8)
459459
460- The ordering of format characters may have an impact on size in native
460+ The ordering of type codes may have an impact on size in native
461461mode since padding is implicit. In standard mode, the user is
462462responsible for inserting any desired padding.
463463Note in
@@ -515,7 +515,7 @@ When constructing format strings which mimic native layouts, the
515515compiler and machine architecture determine byte ordering and padding.
516516In such cases, the ``@ `` format character should be used to specify
517517native byte ordering and data sizes. Internal pad bytes are normally inserted
518- automatically. It is possible that a zero-repeat format code will be
518+ automatically. It is possible that a zero-repeat type code will be
519519needed at the end of a format string to round up to the correct
520520byte boundary for proper alignment of consecutive chunks of data.
521521
@@ -534,7 +534,7 @@ code solves that problem::
534534 >>> calcsize('@llh0l')
535535 24
536536
537- The ``'x' `` format code can be used to specify the repeat, but for
537+ The ``'x' `` type code can be used to specify the repeat, but for
538538native formats it is better to use a zero-repeat format like ``'0l' ``.
539539
540540By default, native byte ordering and alignment is used, but it is
0 commit comments