@@ -10,7 +10,7 @@ \section{Built-in Module \sectcode{array}}
1010type is specified at object creation time by using a \dfn {type code},
1111which is a single character. The following type codes are defined:
1212
13- \begin {tableiii }{|c|c|c|}{code }{Type code}{Type}{Minimum size in bytes}
13+ \begin {tableiii }{|c|c|c|}{character }{Type code}{Type}{Minimum size in bytes}
1414\lineiii {'c'}{character}{1}
1515\lineiii {'b'}{signed integer}{1}
1616\lineiii {'B'}{unsigned integer}{1}
@@ -29,11 +29,10 @@ \section{Built-in Module \sectcode{array}}
2929size can be accessed through the \var {itemsize} attribute. The values
3030stored for \code {'L'} and \code {'I'} items will be represented as
3131Python long integers when retrieved, because Python's plain integer
32- type can't represent the full range of \C {}'s unsigned (long) integers.
32+ type cannot represent the full range of \C {}'s unsigned (long) integers.
3333
34- See also built-in module \module {struct}\refbimodindex {struct}.
3534
36- The module defines the following function:
35+ The module defines the following function and type object :
3736
3837\begin {funcdesc }{array}{typecode\optional {, initializer}}
3938Return a new array whose items are restricted by \var {typecode}, and
@@ -43,67 +42,70 @@ \section{Built-in Module \sectcode{array}}
4342initial items to the array.
4443\end {funcdesc }
4544
46- Array objects support the following data items and methods:
45+ \begin {datadesc }{ArrayType}
46+ Type object corresponding to the objects returned by
47+ \function {array()}.
48+ \end {datadesc }
49+
4750
48- \setindexsubitem {(array attribute)}
51+ Array objects support the following data items and methods:
4952
50- \begin {datadesc } {typecode}
53+ \begin {memberdesc }[array] {typecode}
5154The typecode character used to create the array.
52- \end {datadesc }
55+ \end {memberdesc }
5356
54- \begin {datadesc } {itemsize}
57+ \begin {memberdesc }[array] {itemsize}
5558The length in bytes of one array item in the internal representation.
56- \end {datadesc }
59+ \end {memberdesc }
5760
58- \setindexsubitem {(array method)}
5961
60- \begin {funcdesc } {append}{x}
62+ \begin {methoddesc }[array] {append}{x}
6163Append a new item with value \var {x} to the end of the array.
62- \end {funcdesc }
64+ \end {methoddesc }
6365
64- \begin {funcdesc } {buffer_info}{}
66+ \begin {methoddesc }[array] {buffer_info}{}
6567Return a tuple \code {(\var {address}, \var {length})} giving the current
6668memory address and the length in bytes of the buffer used to hold
6769array's contents. This is occasionally useful when working with
6870low-level (and inherently unsafe) I/O interfaces that require memory
6971addresses, such as certain \cfunction {ioctl()} operations. The returned
7072numbers are valid as long as the array exists and no length-changing
7173operations are applied to it.
72- \end {funcdesc }
74+ \end {methoddesc }
7375
74- \begin {funcdesc } {byteswap}{x}
76+ \begin {methoddesc }[array] {byteswap}{x}
7577`` Byteswap'' all items of the array. This is only supported for
7678integer values. It is useful when reading data from a file written
7779on a machine with a different byte order.
78- \end {funcdesc }
80+ \end {methoddesc }
7981
80- \begin {funcdesc } {fromfile}{f, n}
82+ \begin {methoddesc }[array] {fromfile}{f, n}
8183Read \var {n} items (as machine values) from the file object \var {f}
8284and append them to the end of the array. If less than \var {n} items
8385are available, \exception {EOFError} is raised, but the items that were
8486available are still inserted into the array. \var {f} must be a real
85- built-in file object; something else with a \code {read()} method won't
87+ built-in file object; something else with a \method {read()} method won't
8688do.
87- \end {funcdesc }
89+ \end {methoddesc }
8890
89- \begin {funcdesc } {fromlist}{list}
91+ \begin {methoddesc }[array] {fromlist}{list}
9092Append items from the list. This is equivalent to
9193\samp {for x in \var {list}:\ a.append(x)}
9294except that if there is a type error, the array is unchanged.
93- \end {funcdesc }
95+ \end {methoddesc }
9496
95- \begin {funcdesc } {fromstring}{s}
97+ \begin {methoddesc }[array] {fromstring}{s}
9698Appends items from the string, interpreting the string as an
9799array of machine values (i.e. as if it had been read from a
98100file using the \method {fromfile()} method).
99- \end {funcdesc }
101+ \end {methoddesc }
100102
101- \begin {funcdesc } {insert}{i, x}
103+ \begin {methoddesc }[array] {insert}{i, x}
102104Insert a new item with value \var {x} in the array before position
103105\var {i}.
104- \end {funcdesc }
106+ \end {methoddesc }
105107
106- \begin {funcdesc } {read}{f, n}
108+ \begin {methoddesc }[array] {read}{f, n}
107109\deprecated {1.5.1}
108110 {Use the \method {fromfile()} method.}
109111Read \var {n} items (as machine values) from the file object \var {f}
@@ -112,31 +114,31 @@ \section{Built-in Module \sectcode{array}}
112114available are still inserted into the array. \var {f} must be a real
113115built-in file object; something else with a \method {read()} method won't
114116do.
115- \end {funcdesc }
117+ \end {methoddesc }
116118
117- \begin {funcdesc } {reverse}{}
119+ \begin {methoddesc }[array] {reverse}{}
118120Reverse the order of the items in the array.
119- \end {funcdesc }
121+ \end {methoddesc }
120122
121- \begin {funcdesc } {tofile}{f}
123+ \begin {methoddesc }[array] {tofile}{f}
122124Write all items (as machine values) to the file object \var {f}.
123- \end {funcdesc }
125+ \end {methoddesc }
124126
125- \begin {funcdesc } {tolist}{}
127+ \begin {methoddesc }[array] {tolist}{}
126128Convert the array to an ordinary list with the same items.
127- \end {funcdesc }
129+ \end {methoddesc }
128130
129- \begin {funcdesc } {tostring}{}
131+ \begin {methoddesc }[array] {tostring}{}
130132Convert the array to an array of machine values and return the
131133string representation (the same sequence of bytes that would
132134be written to a file by the \method {tofile()} method.)
133- \end {funcdesc }
135+ \end {methoddesc }
134136
135- \begin {funcdesc } {write}{f}
137+ \begin {methoddesc }[array] {write}{f}
136138\deprecated {1.5.1}
137139 {Use the \method {tofile()} method.}
138140Write all items (as machine values) to the file object \var {f}.
139- \end {funcdesc }
141+ \end {methoddesc }
140142
141143When an array object is printed or converted to a string, it is
142144represented as \code {array(\var {typecode}, \var {initializer})}. The
@@ -152,3 +154,8 @@ \section{Built-in Module \sectcode{array}}
152154array('l', [1, 2, 3, 4, 5])
153155array('d', [1.0, 2.0, 3.14])
154156\end {verbatim }
157+
158+
159+ \begin {seealso }
160+ \seemodule {struct}{Packing and unpacking of heterogeneous binary data.}
161+ \end {seealso }
0 commit comments