Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd1f52b

Browse files
committed
Use {seealso} environment to refer to the struct module.
Document ArrayType. Use {memberdesc} and {methoddesc} environments, as appropriate. Minor nits.
1 parent 5a52519 commit dd1f52b

2 files changed

Lines changed: 90 additions & 76 deletions

File tree

Doc/lib/libarray.tex

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ \section{Built-in Module \sectcode{array}}
1010
type is specified at object creation time by using a \dfn{type code},
1111
which 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}}
2929
size can be accessed through the \var{itemsize} attribute. The values
3030
stored for \code{'L'} and \code{'I'} items will be represented as
3131
Python 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}}
3938
Return a new array whose items are restricted by \var{typecode}, and
@@ -43,67 +42,70 @@ \section{Built-in Module \sectcode{array}}
4342
initial 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}
5154
The typecode character used to create the array.
52-
\end{datadesc}
55+
\end{memberdesc}
5356

54-
\begin{datadesc}{itemsize}
57+
\begin{memberdesc}[array]{itemsize}
5558
The 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}
6163
Append 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}{}
6567
Return a tuple \code{(\var{address}, \var{length})} giving the current
6668
memory address and the length in bytes of the buffer used to hold
6769
array's contents. This is occasionally useful when working with
6870
low-level (and inherently unsafe) I/O interfaces that require memory
6971
addresses, such as certain \cfunction{ioctl()} operations. The returned
7072
numbers are valid as long as the array exists and no length-changing
7173
operations 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
7678
integer values. It is useful when reading data from a file written
7779
on 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}
8183
Read \var{n} items (as machine values) from the file object \var{f}
8284
and append them to the end of the array. If less than \var{n} items
8385
are available, \exception{EOFError} is raised, but the items that were
8486
available 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
8688
do.
87-
\end{funcdesc}
89+
\end{methoddesc}
8890

89-
\begin{funcdesc}{fromlist}{list}
91+
\begin{methoddesc}[array]{fromlist}{list}
9092
Append items from the list. This is equivalent to
9193
\samp{for x in \var{list}:\ a.append(x)}
9294
except 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}
9698
Appends items from the string, interpreting the string as an
9799
array of machine values (i.e. as if it had been read from a
98100
file 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}
102104
Insert 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.}
109111
Read \var{n} items (as machine values) from the file object \var{f}
@@ -112,31 +114,31 @@ \section{Built-in Module \sectcode{array}}
112114
available are still inserted into the array. \var{f} must be a real
113115
built-in file object; something else with a \method{read()} method won't
114116
do.
115-
\end{funcdesc}
117+
\end{methoddesc}
116118

117-
\begin{funcdesc}{reverse}{}
119+
\begin{methoddesc}[array]{reverse}{}
118120
Reverse 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}
122124
Write 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}{}
126128
Convert 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}{}
130132
Convert the array to an array of machine values and return the
131133
string representation (the same sequence of bytes that would
132134
be 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.}
138140
Write all items (as machine values) to the file object \var{f}.
139-
\end{funcdesc}
141+
\end{methoddesc}
140142

141143
When an array object is printed or converted to a string, it is
142144
represented as \code{array(\var{typecode}, \var{initializer})}. The
@@ -152,3 +154,8 @@ \section{Built-in Module \sectcode{array}}
152154
array('l', [1, 2, 3, 4, 5])
153155
array('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}

Doc/libarray.tex

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ \section{Built-in Module \sectcode{array}}
1010
type is specified at object creation time by using a \dfn{type code},
1111
which 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}}
2929
size can be accessed through the \var{itemsize} attribute. The values
3030
stored for \code{'L'} and \code{'I'} items will be represented as
3131
Python 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}}
3938
Return a new array whose items are restricted by \var{typecode}, and
@@ -43,67 +42,70 @@ \section{Built-in Module \sectcode{array}}
4342
initial 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}
5154
The typecode character used to create the array.
52-
\end{datadesc}
55+
\end{memberdesc}
5356

54-
\begin{datadesc}{itemsize}
57+
\begin{memberdesc}[array]{itemsize}
5558
The 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}
6163
Append 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}{}
6567
Return a tuple \code{(\var{address}, \var{length})} giving the current
6668
memory address and the length in bytes of the buffer used to hold
6769
array's contents. This is occasionally useful when working with
6870
low-level (and inherently unsafe) I/O interfaces that require memory
6971
addresses, such as certain \cfunction{ioctl()} operations. The returned
7072
numbers are valid as long as the array exists and no length-changing
7173
operations 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
7678
integer values. It is useful when reading data from a file written
7779
on 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}
8183
Read \var{n} items (as machine values) from the file object \var{f}
8284
and append them to the end of the array. If less than \var{n} items
8385
are available, \exception{EOFError} is raised, but the items that were
8486
available 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
8688
do.
87-
\end{funcdesc}
89+
\end{methoddesc}
8890

89-
\begin{funcdesc}{fromlist}{list}
91+
\begin{methoddesc}[array]{fromlist}{list}
9092
Append items from the list. This is equivalent to
9193
\samp{for x in \var{list}:\ a.append(x)}
9294
except 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}
9698
Appends items from the string, interpreting the string as an
9799
array of machine values (i.e. as if it had been read from a
98100
file 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}
102104
Insert 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.}
109111
Read \var{n} items (as machine values) from the file object \var{f}
@@ -112,31 +114,31 @@ \section{Built-in Module \sectcode{array}}
112114
available are still inserted into the array. \var{f} must be a real
113115
built-in file object; something else with a \method{read()} method won't
114116
do.
115-
\end{funcdesc}
117+
\end{methoddesc}
116118

117-
\begin{funcdesc}{reverse}{}
119+
\begin{methoddesc}[array]{reverse}{}
118120
Reverse 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}
122124
Write 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}{}
126128
Convert 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}{}
130132
Convert the array to an array of machine values and return the
131133
string representation (the same sequence of bytes that would
132134
be 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.}
138140
Write all items (as machine values) to the file object \var{f}.
139-
\end{funcdesc}
141+
\end{methoddesc}
140142

141143
When an array object is printed or converted to a string, it is
142144
represented as \code{array(\var{typecode}, \var{initializer})}. The
@@ -152,3 +154,8 @@ \section{Built-in Module \sectcode{array}}
152154
array('l', [1, 2, 3, 4, 5])
153155
array('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

Comments
 (0)