diff options
author | Fred Drake <fdrake@acm.org> | 1998-02-27 15:19:42 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1998-02-27 15:19:42 (GMT) |
commit | 8a13525274e388b5d11a7325e7002665551f6546 (patch) | |
tree | ea6ebefe5dba423bd11914631a9eff4c03814b14 /Doc/lib | |
parent | 4f56f2d64668b37f8b36545dee3960f10047af28 (diff) | |
download | cpython-8a13525274e388b5d11a7325e7002665551f6546.zip cpython-8a13525274e388b5d11a7325e7002665551f6546.tar.gz cpython-8a13525274e388b5d11a7325e7002665551f6546.tar.bz2 |
Updates by AMK.
Markup corrected, logical markup.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libarray.tex | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/Doc/lib/libarray.tex b/Doc/lib/libarray.tex index 7ba3954..2bcfb5d 100644 --- a/Doc/lib/libarray.tex +++ b/Doc/lib/libarray.tex @@ -10,7 +10,7 @@ except that the type of objects stored in them is constrained. The type is specified at object creation time by using a \dfn{type code}, which is a single character. The following type codes are defined: -\begin{tableiii}{|c|c|c|}{code}{Typecode}{Type}{Minimal size in bytes} +\begin{tableiii}{|c|c|c|}{code}{Type code}{Type}{Minimum size in bytes} \lineiii{'c'}{character}{1} \lineiii{'b'}{signed integer}{1} \lineiii{'B'}{unsigned integer}{1} @@ -25,29 +25,28 @@ which is a single character. The following type codes are defined: \end{tableiii} The actual representation of values is determined by the machine -architecture (strictly speaking, by the C implementation). The actual +architecture (strictly speaking, by the \C{} implementation). The actual size can be accessed through the \var{itemsize} attribute. The values stored for \code{'L'} and \code{'I'} items will be represented as Python long integers when retrieved, because Python's plain integer -type can't represent the full range of C's unsigned (long) integers. +type can't represent the full range of \C{}'s unsigned (long) integers. -See also built-in module \code{struct}. -\refbimodindex{struct} +See also built-in module \module{struct}\refbimodindex{struct}. The module defines the following function: -\setindexsubitem{(in module array)} - \begin{funcdesc}{array}{typecode\optional{\, initializer}} Return a new array whose items are restricted by \var{typecode}, and initialized from the optional \var{initializer} value, which must be a list or a string. The list or string is passed to the new array's -\code{fromlist()} or \code{fromstring()} method (see below) to add +\method{fromlist()} or \method{fromstring()} method (see below) to add initial items to the array. \end{funcdesc} Array objects support the following data items and methods: +\setindexsubitem{(array attribute)} + \begin{datadesc}{typecode} The typecode character used to create the array. \end{datadesc} @@ -56,6 +55,8 @@ The typecode character used to create the array. The length in bytes of one array item in the internal representation. \end{datadesc} +\setindexsubitem{(array method)} + \begin{funcdesc}{append}{x} Append a new item with value \var{x} to the end of the array. \end{funcdesc} @@ -65,7 +66,7 @@ Return a tuple \code{(\var{address}, \var{length})} giving the current memory address and the length in bytes of the buffer used to hold array's contents. This is occasionally useful when working with low-level (and inherently unsafe) I/O interfaces that require memory -addresses, such as certain \code{ioctl} operations. The returned +addresses, such as certain \cfunction{ioctl()} operations. The returned numbers are valid as long as the array exists and no length-changing operations are applied to it. \end{funcdesc} @@ -79,22 +80,24 @@ on a machine with a different byte order. \begin{funcdesc}{fromfile}{f\, n} Read \var{n} items (as machine values) from the file object \var{f} and append them to the end of the array. If less than \var{n} items -are available, \code{EOFError} is raised, but the items that were +are available, \exception{EOFError} is raised, but the items that were available are still inserted into the array. \var{f} must be a real built-in file object; something else with a \code{read()} method won't do. + +Also available as the \method{read()} method. \end{funcdesc} \begin{funcdesc}{fromlist}{list} Append items from the list. This is equivalent to -\code{for x in \var{list}:\ a.append(x)} +\samp{for x in \var{list}:\ a.append(x)} except that if there is a type error, the array is unchanged. \end{funcdesc} \begin{funcdesc}{fromstring}{s} Appends items from the string, interpreting the string as an array of machine values (i.e. as if it had been read from a -file using the \code{fromfile()} method). +file using the \method{fromfile()} method). \end{funcdesc} \begin{funcdesc}{insert}{i\, x} @@ -102,8 +105,25 @@ Insert a new item with value \var{x} in the array before position \var{i}. \end{funcdesc} +\begin{funcdesc}{read}{f\, n} +Read \var{n} items (as machine values) from the file object \var{f} +and append them to the end of the array. If less than \var{n} items +are available, \exception{EOFError} is raised, but the items that were +available are still inserted into the array. \var{f} must be a real +built-in file object; something else with a \method{read()} method won't +do. + +Also available as the \method{fromfile()} method. +\end{funcdesc} + +\begin{funcdesc}{reverse}{} +Reverse the order of the items in the array. +\end{funcdesc} + \begin{funcdesc}{tofile}{f} Write all items (as machine values) to the file object \var{f}. + +Also available as the \function{write()} function. \end{funcdesc} \begin{funcdesc}{tolist}{} @@ -113,7 +133,13 @@ Convert the array to an ordinary list with the same items. \begin{funcdesc}{tostring}{} Convert the array to an array of machine values and return the string representation (the same sequence of bytes that would -be written to a file by the \code{tofile()} method.) +be written to a file by the \method{tofile()} method.) +\end{funcdesc} + +\begin{funcdesc}{write}{f} +Write all items (as machine values) to the file object \var{f}. + +Also available as the \function{write()} function. \end{funcdesc} When an array object is printed or converted to a string, it is |