Markup nits.

Fixes/index improvements from Michael Ernst <mernst@cs.washington.edu>.
This commit is contained in:
Fred Drake 1998-09-10 18:25:58 +00:00
parent 106a470da2
commit 7a2f0668e4
1 changed files with 63 additions and 65 deletions

View File

@ -1,5 +1,4 @@
\section{Built-in Types} \section{Built-in Types \label{types}}
\label{types}
The following sections describe the standard types that are built into The following sections describe the standard types that are built into
the interpreter. These are the numeric types, sequence types, and the interpreter. These are the numeric types, sequence types, and
@ -15,8 +14,7 @@ implicitly used when an object is written by the \code{print} statement.
\stindex{print} \stindex{print}
\subsection{Truth Value Testing} \subsection{Truth Value Testing \label{truth}}
\label{truth}
Any object can be tested for truth value, for use in an \code{if} or Any object can be tested for truth value, for use in an \code{if} or
\code{while} condition or as operand of the Boolean operations below. \code{while} condition or as operand of the Boolean operations below.
@ -27,11 +25,10 @@ The following values are considered false:
\indexii{Boolean}{operations} \indexii{Boolean}{operations}
\index{false} \index{false}
\setindexsubitem{(Built-in object)}
\begin{itemize} \begin{itemize}
\item \code{None} \item \code{None}
\ttindex{None} \withsubitem{(Built-in object)}{\ttindex{None}}
\item zero of any numeric type, e.g., \code{0}, \code{0L}, \code{0.0}. \item zero of any numeric type, e.g., \code{0}, \code{0L}, \code{0.0}.
@ -40,7 +37,7 @@ The following values are considered false:
\item any empty mapping, e.g., \code{\{\}}. \item any empty mapping, e.g., \code{\{\}}.
\item instances of user-defined classes, if the class defines a \item instances of user-defined classes, if the class defines a
\code{__nonzero__()} or \code{__len__()} method, when that \method{__nonzero__()} or \method{__len__()} method, when that
method returns zero. method returns zero.
\end{itemize} \end{itemize}
@ -56,8 +53,7 @@ stated. (Important exception: the Boolean operations
their operands.) their operands.)
\subsection{Boolean Operations} \subsection{Boolean Operations \label{boolean}}
\label{boolean}
These are the Boolean operations, ordered by ascending priority: These are the Boolean operations, ordered by ascending priority:
\indexii{Boolean}{operations} \indexii{Boolean}{operations}
@ -88,8 +84,7 @@ These only evaluate their second argument if needed for their outcome.
\end{description} \end{description}
\subsection{Comparisons} \subsection{Comparisons \label{comparisons}}
\label{comparisons}
Comparison operations are supported by all objects. They all have the Comparison operations are supported by all objects. They all have the
same priority (which is higher than that of the Boolean operations). same priority (which is higher than that of the Boolean operations).
@ -150,8 +145,7 @@ Two more operations with the same syntactic priority, \samp{in} and
\opindex{not in} \opindex{not in}
\subsection{Numeric Types} \subsection{Numeric Types \label{typesnumeric}}
\label{typesnumeric}
There are four numeric types: \dfn{plain integers}, \dfn{long integers}, There are four numeric types: \dfn{plain integers}, \dfn{long integers},
\dfn{floating point numbers}, and \dfn{complex numbers}. \dfn{floating point numbers}, and \dfn{complex numbers}.
@ -302,8 +296,7 @@ division by \code{pow(2, \var{n})} without overflow check.
\end{description} \end{description}
\subsection{Sequence Types} \subsection{Sequence Types \label{typesseq}}
\label{typesseq}
There are three sequence types: strings, lists and tuples. There are three sequence types: strings, lists and tuples.
@ -481,16 +474,16 @@ The following operations are defined on mutable sequence types (where
\indexii{subscript}{assignment} \indexii{subscript}{assignment}
\indexii{slice}{assignment} \indexii{slice}{assignment}
\stindex{del} \stindex{del}
\setindexsubitem{(list method)} \withsubitem{(list method)}{%
\ttindex{append} \ttindex{append}%
\ttindex{count} \ttindex{count}%
\ttindex{index} \ttindex{index}%
\ttindex{insert} \ttindex{insert}%
\ttindex{pop} \ttindex{pop}%
\ttindex{remove} \ttindex{remove}%
\ttindex{reverse} \ttindex{reverse}%
\ttindex{sort} \ttindex{sort}%
}
\noindent \noindent
Notes: Notes:
\begin{description} \begin{description}
@ -519,8 +512,7 @@ by default the last item is removed and returned.
\end{description} \end{description}
\subsection{Mapping Types} \subsection{Mapping Types \label{typesmapping}}
\label{typesmapping}
A \dfn{mapping} object maps values of one type (the key type) to A \dfn{mapping} object maps values of one type (the key type) to
arbitrary objects. Mappings are mutable objects. There is currently arbitrary objects. Mappings are mutable objects. There is currently
@ -552,20 +544,26 @@ mapping, \var{k} is a key and \var{x} is an arbitrary object):
\lineiii{\var{a}.clear()}{remove all items from \code{a}}{} \lineiii{\var{a}.clear()}{remove all items from \code{a}}{}
\lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{} \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{}
\lineiii{\var{a}.has_key(\var{k})}{\code{1} if \var{a} has a key \var{k}, else \code{0}}{} \lineiii{\var{a}.has_key(\var{k})}{\code{1} if \var{a} has a key \var{k}, else \code{0}}{}
\lineiii{\var{a}.items()}{a copy of \var{a}'s list of (key, item) pairs}{(2)} \lineiii{\var{a}.items()}{a copy of \var{a}'s list of (\var{key}, \var{value}) pairs}{(2)}
\lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(2)} \lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(2)}
\lineiii{\var{a}.update(\var{b})}{\code{for k, v in \var{b}.items(): \var{a}[k] = v}}{(3)} \lineiii{\var{a}.update(\var{b})}{\code{for k, v in \var{b}.items(): \var{a}[k] = v}}{(3)}
\lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)} \lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)}
\lineiii{\var{a}.get(\var{k}\optional{, \var{f}})}{the item of \var{a} with key \var{k}}{(4)} \lineiii{\var{a}.get(\var{k}\optional{, \var{f}})}{the value of \var{a} with key \var{k}}{(4)}
\end{tableiii} \end{tableiii}
\indexiii{operations on}{mapping}{types} \indexiii{operations on}{mapping}{types}
\indexiii{operations on}{dictionary}{type} \indexiii{operations on}{dictionary}{type}
\stindex{del} \stindex{del}
\bifuncindex{len} \bifuncindex{len}
\setindexsubitem{(dictionary method)} \withsubitem{(dictionary method)}{%
\ttindex{keys} \ttindex{clear}%
\ttindex{has_key} \ttindex{copy}%
\ttindex{has_key}%
\ttindex{items}%
\ttindex{keys}%
\ttindex{update}%
\ttindex{values}%
\ttindex{get}%
}
\noindent \noindent
Notes: Notes:
\begin{description} \begin{description}
@ -581,8 +579,7 @@ and \var{k} is not in the map, \code{None} is returned.
\end{description} \end{description}
\subsection{Other Built-in Types} \subsection{Other Built-in Types \label{typesother}}
\label{typesother}
The interpreter supports several other kinds of objects. The interpreter supports several other kinds of objects.
Most of these support only one or two operations. Most of these support only one or two operations.
@ -650,7 +647,8 @@ calling \code{\var{m}.im_func(\var{m}.im_self, \var{arg-1},
See the \emph{Python Reference Manual} for more information. See the \emph{Python Reference Manual} for more information.
\subsubsection{Code Objects}
\subsubsection{Code Objects \label{bltin-code-objects}}
\obindex{code} \obindex{code}
Code objects are used by the implementation to represent Code objects are used by the implementation to represent
@ -661,7 +659,7 @@ returned by the built-in \code{compile()} function and can be
extracted from function objects through their \code{func_code} extracted from function objects through their \code{func_code}
attribute. attribute.
\bifuncindex{compile} \bifuncindex{compile}
\ttindex{func_code} \withsubitem{(code object attribute)}{\ttindex{func_code}}
A code object can be executed or evaluated by passing it (instead of a A code object can be executed or evaluated by passing it (instead of a
source string) to the \code{exec} statement or the built-in source string) to the \code{exec} statement or the built-in
@ -671,8 +669,8 @@ source string) to the \code{exec} statement or the built-in
See the \emph{Python Reference Manual} for more information. See the \emph{Python Reference Manual} for more information.
\subsubsection{Type Objects}
\label{bltin-type-objects} \subsubsection{Type Objects \label{bltin-type-objects}}
Type objects represent the various object types. An object's type is Type objects represent the various object types. An object's type is
accessed by the built-in function \code{type()}. There are no special accessed by the built-in function \code{type()}. There are no special
@ -683,8 +681,8 @@ for all standard built-in types.
Types are written like this: \code{<type 'int'>}. Types are written like this: \code{<type 'int'>}.
\subsubsection{The Null Object}
\label{bltin-null-object} \subsubsection{The Null Object \label{bltin-null-object}}
This object is returned by functions that don't explicitly return a This object is returned by functions that don't explicitly return a
value. It supports no special operations. There is exactly one null value. It supports no special operations. There is exactly one null
@ -692,8 +690,8 @@ object, named \code{None} (a built-in name).
It is written as \code{None}. It is written as \code{None}.
\subsubsection{The Ellipsis Object}
\label{bltin-ellipsis-object} \subsubsection{The Ellipsis Object \label{bltin-ellipsis-object}}
This object is used by extended slice notation (see the \emph{Python This object is used by extended slice notation (see the \emph{Python
Reference Manual}). It supports no special operations. There is Reference Manual}). It supports no special operations. There is
@ -701,14 +699,13 @@ exactly one ellipsis object, named \code{Ellipsis} (a built-in name).
It is written as \code{Ellipsis}. It is written as \code{Ellipsis}.
\subsubsection{File Objects} \subsubsection{File Objects \label{bltin-file-objects}}
\label{bltin-file-objects}
File objects are implemented using \C{}'s \code{stdio} package and can be File objects are implemented using \C{}'s \code{stdio} package and can be
created with the built-in function \code{open()} described under created with the built-in function \code{open()} described under
Built-in Functions below. They are also returned by some other Built-in Functions below. They are also returned by some other
built-in functions and methods, e.g.\ \code{posix.popen()} and built-in functions and methods, e.g.\ \function{posix.popen()} and
\code{posix.fdopen()} and the \code{makefile()} method of socket \function{posix.fdopen()} and the \method{makefile()} method of socket
objects. objects.
\bifuncindex{open} \bifuncindex{open}
\refbimodindex{posix} \refbimodindex{posix}
@ -851,30 +848,31 @@ describes code objects, stack frame objects, traceback objects, and
slice objects. slice objects.
\subsection{Special Attributes} \subsection{Special Attributes \label{specialattrs}}
\label{specialattrs}
The implementation adds a few special read-only attributes to several The implementation adds a few special read-only attributes to several
object types, where they are relevant: object types, where they are relevant:
\begin{itemize} \begin{memberdescni}{__dict__}
A dictionary of some sort used to store an
object's (writable) attributes.
\end{memberdescni}
\item \begin{memberdescni}{__methods__}
\code{\var{x}.__dict__} is a dictionary of some sort used to store an List of the methods of many built-in object types,
object's (writable) attributes;
\item
\code{\var{x}.__methods__} lists the methods of many built-in object types,
e.g., \code{[].__methods__} yields e.g., \code{[].__methods__} yields
\code{['append', 'count', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']}; \code{['append', 'count', 'index', 'insert', 'pop', 'remove',
'reverse', 'sort']}.
\end{memberdescni}
\item \begin{memberdescni}{__members__}
\code{\var{x}.__members__} lists data attributes; Similar to \member{__methods__}, but lists data attributes.
\end{memberdescni}
\item \begin{memberdescni}{__class__}
\code{\var{x}.__class__} is the class to which a class instance belongs; The class to which a class instance belongs.
\end{memberdescni}
\item \begin{memberdescni}{__bases__}
\code{\var{x}.__bases__} is the tuple of base classes of a class object. The tuple of base classes of a class object.
\end{memberdescni}
\end{itemize}