Kaydet (Commit) 293dd4b7 authored tarafından Fred Drake's avatar Fred Drake

Fix up Guido's markup.

üst 16c8d702
...@@ -12,7 +12,7 @@ program is represented by objects or by relations between objects. ...@@ -12,7 +12,7 @@ program is represented by objects or by relations between objects.
Every object has an identity, a type and a value. An object's Every object has an identity, a type and a value. An object's
\emph{identity} never changes once it has been created; you may think \emph{identity} never changes once it has been created; you may think
of it as the object's address in memory. The `\code{is}' operator of it as the object's address in memory. The `\keyword{is}' operator
compares the identity of two objects; the compares the identity of two objects; the
\function{id()}\bifuncindex{id} function returns an integer \function{id()}\bifuncindex{id} function returns an integer
representing its identity (currently implemented as its address). representing its identity (currently implemented as its address).
...@@ -1540,10 +1540,10 @@ original arguments to the operation. ...@@ -1540,10 +1540,10 @@ original arguments to the operation.
\item \item
New-style classes (those derived from \code{object}) never invoke the New-style classes (those derived from \class{object}) never invoke the
\code{__coerce__} method in response to a binary operator; the only \method{__coerce__()} method in response to a binary operator; the only
time \code{__coerce__} is invoked is when the built-in function time \method{__coerce__()} is invoked is when the built-in function
\code{coerce()} is called. \function{coerce()} is called.
\item \item
...@@ -1565,7 +1565,7 @@ binary operator, and \method{__iadd__} for the in-place variant. ...@@ -1565,7 +1565,7 @@ binary operator, and \method{__iadd__} for the in-place variant.
For objects \var{x} and \var{y}, first \code{\var{x}.__op__(\var{y})} For objects \var{x} and \var{y}, first \code{\var{x}.__op__(\var{y})}
is tried. If this is not implemented or returns \code{NotImplemented}, is tried. If this is not implemented or returns \code{NotImplemented},
\code{\var{y}.__rop__(\var{x})} is tried. If this is also not \code{\var{y}.__rop__(\var{x})} is tried. If this is also not
implemented or returns \code{NotImplemented}, a \code{TypeError} implemented or returns \code{NotImplemented}, a \exception{TypeError}
exception is raised. But see the following exception: exception is raised. But see the following exception:
\item \item
...@@ -1573,8 +1573,8 @@ exception is raised. But see the following exception: ...@@ -1573,8 +1573,8 @@ exception is raised. But see the following exception:
Exception to the previous item: if the left operand is an instance of Exception to the previous item: if the left operand is an instance of
a built-in type or a new-style class, and the right operand is an a built-in type or a new-style class, and the right operand is an
instance of a proper subclass of that type or class, the right instance of a proper subclass of that type or class, the right
operand's \code{__rop__} method is tried \emph{before} the left operand's \method{__rop__()} method is tried \emph{before} the left
operand's \code{__op__} method. This is done so that a subclass can operand's \method{__op__()} method. This is done so that a subclass can
completely override binary operators. Otherwise, the left operand's completely override binary operators. Otherwise, the left operand's
__op__ method would always accept the right operand: when an instance __op__ method would always accept the right operand: when an instance
of a given class is expected, an instance of a subclass of that class of a given class is expected, an instance of a subclass of that class
...@@ -1583,17 +1583,17 @@ is always acceptable. ...@@ -1583,17 +1583,17 @@ is always acceptable.
\item \item
When either operand type defines a coercion, this coercion is called When either operand type defines a coercion, this coercion is called
before that type's \code{__op__} or \code{__rop__} method is called, before that type's \method{__op__()} or \method{__rop__()} method is
but no sooner. If the coercion returns an object of a different type called, but no sooner. If the coercion returns an object of a
for the operand whose coercion is invoked, part of the process is different type for the operand whose coercion is invoked, part of the
redone using the new object. process is redone using the new object.
\item \item
When an in-place operator (like `\code{+=}') is used, if the left When an in-place operator (like `\code{+=}') is used, if the left
operand implements \code{__iop__}, it is invoked without any coercion. operand implements \method{__iop__()}, it is invoked without any
When the operation falls back to \code{__op__} and/or \code{__rop__}, coercion. When the operation falls back to \method{__op__()} and/or
the normal coercion rules apply. \method{__rop__()}, the normal coercion rules apply.
\item \item
...@@ -1604,23 +1604,23 @@ sequence concatenation, sequence concatenation is invoked. ...@@ -1604,23 +1604,23 @@ sequence concatenation, sequence concatenation is invoked.
In \var{x}\code{*}\var{y}, if one operator is a sequence that In \var{x}\code{*}\var{y}, if one operator is a sequence that
implements sequence repetition, and the other is an integer implements sequence repetition, and the other is an integer
(\code{int} or \code{long}), sequence repetition is invoked. (\class{int} or \class{long}), sequence repetition is invoked.
\item \item
Rich comparisons (implemented by methods \code{__eq__} and so on) Rich comparisons (implemented by methods \method{__eq__()} and so on)
never use coercion. Three-way comparison (implemented by never use coercion. Three-way comparison (implemented by
\code{__cmp__}) does use coercion under the same conditions as \method{__cmp__()}) does use coercion under the same conditions as
other binary operations use it. other binary operations use it.
\item \item
In the current implementation, the built-in numeric types \code{int}, In the current implementation, the built-in numeric types \class{int},
\code{long} and \code{float} do not use coercion; the type \class{long} and \class{float} do not use coercion; the type
\code{complex} however does use it. The difference can become \class{complex} however does use it. The difference can become
apparent when subclassing these types. Over time, the type apparent when subclassing these types. Over time, the type
\code{complex} may be fixed to avoid coercion. All these types \class{complex} may be fixed to avoid coercion. All these types
implement a \code{__coerce__} method, for use by the built-in implement a \method{__coerce__()} method, for use by the built-in
\code{coerce} function. \function{coerce()} function.
\end{itemize} \end{itemize}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment