Merge alpha100 branch back to main trunk
diff --git a/Doc/ref/ref.tex b/Doc/ref/ref.tex
index f0cb559..11a5d08 100644
--- a/Doc/ref/ref.tex
+++ b/Doc/ref/ref.tex
@@ -1,6 +1,6 @@
\documentstyle[twoside,11pt,myformat]{report}
-\title{\bf Python Reference Manual}
+\title{Python Reference Manual}
\author{
Guido van Rossum \\
@@ -9,7 +9,7 @@
E-mail: {\tt guido@cwi.nl}
}
-\date{19 November 1993 \\ Release 0.9.9.++} % XXX update before release!
+\date{14 Jul 1994 \\ Release 1.0.3} % XXX update before release!
% Tell \index to actually write the .idx file
\makeindex
diff --git a/Doc/ref/ref1.tex b/Doc/ref/ref1.tex
index b373e36..169c244 100644
--- a/Doc/ref/ref1.tex
+++ b/Doc/ref/ref1.tex
@@ -43,22 +43,22 @@
lc_letter: "a"..."z"
\end{verbatim}
-The first line says that a \verb\name\ is an \verb\lc_letter\ followed by
-a sequence of zero or more \verb\lc_letter\s and underscores. An
-\verb\lc_letter\ in turn is any of the single characters `a' through `z'.
+The first line says that a \verb@name@ is an \verb@lc_letter@ followed by
+a sequence of zero or more \verb@lc_letter@s and underscores. An
+\verb@lc_letter@ in turn is any of the single characters `a' through `z'.
(This rule is actually adhered to for the names defined in lexical and
grammar rules in this document.)
Each rule begins with a name (which is the name defined by the rule)
-and a colon. A vertical bar (\verb\|\) is used to separate
+and a colon. A vertical bar (\verb@|@) is used to separate
alternatives; it is the least binding operator in this notation. A
-star (\verb\*\) means zero or more repetitions of the preceding item;
-likewise, a plus (\verb\+\) means one or more repetitions, and a
-phrase enclosed in square brackets (\verb\[ ]\) means zero or one
+star (\verb@*@) means zero or more repetitions of the preceding item;
+likewise, a plus (\verb@+@) means one or more repetitions, and a
+phrase enclosed in square brackets (\verb@[ ]@) means zero or one
occurrences (in other words, the enclosed phrase is optional). The
-\verb\*\ and \verb\+\ operators bind as tightly as possible;
+\verb@*@ and \verb@+@ operators bind as tightly as possible;
parentheses are used for grouping. Literal strings are enclosed in
-double quotes. White space is only meaningful to separate tokens.
+quotes. White space is only meaningful to separate tokens.
Rules are normally contained on a single line; rules with many
alternatives may be formatted alternatively with each line after the
first beginning with a vertical bar.
@@ -66,7 +66,7 @@
In lexical definitions (as the example above), two more conventions
are used: Two literal characters separated by three dots mean a choice
of any single character in the given (inclusive) range of ASCII
-characters. A phrase between angular brackets (\verb\<...>\) gives an
+characters. A phrase between angular brackets (\verb@<...>@) gives an
informal description of the symbol defined; e.g. this could be used
to describe the notion of `control character' if needed.
\index{lexical definitions}
diff --git a/Doc/ref/ref2.tex b/Doc/ref/ref2.tex
index 250bd2e..67f22f8 100644
--- a/Doc/ref/ref2.tex
+++ b/Doc/ref/ref2.tex
@@ -19,7 +19,7 @@
\subsection{Comments}
-A comment starts with a hash character (\verb\#\) that is not part of
+A comment starts with a hash character (\verb@#@) that is not part of
a string literal, and ends at the end of the physical line. A comment
always signifies the end of the logical line. Comments are ignored by
the syntax.
@@ -28,7 +28,7 @@
\index{physical line}
\index{hash character}
-\subsection{Line joining}
+\subsection{Explicit line joining}
Two or more physical lines may be joined into logical lines using
backslash characters (\verb/\/), as follows: when a physical line ends
@@ -37,15 +37,37 @@
backslash and the following end-of-line character. For example:
\index{physical line}
\index{line joining}
+\index{line continuation}
\index{backslash character}
%
\begin{verbatim}
-month_names = ['Januari', 'Februari', 'Maart', \
- 'April', 'Mei', 'Juni', \
- 'Juli', 'Augustus', 'September', \
- 'Oktober', 'November', 'December']
+if 1900 < year < 2100 and 1 <= month <= 12 \
+ and 1 <= day <= 31 and 0 <= hour < 24 \
+ and 0 <= minute < 60 and 0 <= second < 60: # Looks like a valid date
+ return 1
\end{verbatim}
+A line ending in a backslash cannot carry a comment; a backslash does
+not continue a comment (but it does continue a string literal, see
+below).
+
+\subsection{Implicit line joining}
+
+Expressions in parentheses, square brackets or curly braces can be
+split over more than one physical line without using backslashes.
+For example:
+
+\begin{verbatim}
+month_names = ['Januari', 'Februari', 'Maart', # These are the
+ 'April', 'Mei', 'Juni', # Dutch names
+ 'Juli', 'Augustus', 'September', # for the months
+ 'Oktober', 'November', 'December'] # of the year
+\end{verbatim}
+
+Implicitly continued lines can carry comments. The indentation of the
+continuation lines is not important. Blank continuation lines are
+allowed.
+
\subsection{Blank lines}
A logical line that contains only spaces, tabs, and possibly a
@@ -123,7 +145,7 @@
(Actually, the first three errors are detected by the parser; only the
last error is found by the lexical analyzer --- the indentation of
-\verb\return r\ does not match a level popped off the stack.)
+\verb@return r@ does not match a level popped off the stack.)
\section{Other tokens}
@@ -159,26 +181,15 @@
\index{reserved word}
\begin{verbatim}
-and del for in print
-break elif from is raise
-class else global not return
-continue except if or try
-def finally import pass while
+access del from lambda return
+and elif global not try
+break else if or while
+class except import pass
+continue finally in print
+def for is raise
\end{verbatim}
-% # This Python program sorts and formats the above table
-% import string
-% l = []
-% try:
-% while 1:
-% l = l + string.split(raw_input())
-% except EOFError:
-% pass
-% l.sort()
-% for i in range((len(l)+4)/5):
-% for j in range(i, len(l), 5):
-% print string.ljust(l[j], 10),
-% print
+% When adding keywords, pipe it through keywords.py for reformatting
\section{Literals} \label{literals}
@@ -192,17 +203,24 @@
\index{string literal}
\begin{verbatim}
-stringliteral: "'" stringitem* "'"
-stringitem: stringchar | escapeseq
-stringchar: <any ASCII character except newline or "\" or "'">
-escapeseq: "'" <any ASCII character except newline>
+stringliteral: shortstring | longstring
+shortstring: "'" shortstringitem* "'" | '"' shortstringitem* '"'
+longstring: "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
+shortstringitem: shortstringchar | escapeseq
+shortstringchar: <any ASCII character except "\" or newline or the quote>
+longstringchar: <any ASCII character except "\">
+escapeseq: "\" <any ASCII character>
\end{verbatim}
\index{ASCII}
-String literals cannot span physical line boundaries. Escape
-sequences in strings are actually interpreted according to rules
-similar to those used by Standard C. The recognized escape sequences
-are:
+In ``long strings'' (strings surrounded by sets of three quotes),
+unescaped newlines and quotes are allowed (and are retained), except
+that three unescaped quotes in a row terminate the string. (A
+``quote'' is the character used to open the string, i.e. either
+\verb/'/ or \verb/"/.)
+
+Escape sequences in strings are interpreted according to rules similar
+to those used by Standard C. The recognized escape sequences are:
\index{physical line}
\index{escape sequence}
\index{Standard C}
@@ -211,8 +229,10 @@
\begin{center}
\begin{tabular}{|l|l|}
\hline
+\verb/\/{\em newline} & Ignored \\
\verb/\\/ & Backslash (\verb/\/) \\
\verb/\'/ & Single quote (\verb/'/) \\
+\verb/\"/ & Double quote (\verb/"/) \\
\verb/\a/ & ASCII Bell (BEL) \\
\verb/\b/ & ASCII Backspace (BS) \\
%\verb/\E/ & ASCII Escape (ESC) \\
@@ -309,8 +329,8 @@
\end{verbatim}
Note that numeric literals do not include a sign; a phrase like
-\verb\-1\ is actually an expression composed of the operator
-\verb\-\ and the literal \verb\1\.
+\verb@-1@ is actually an expression composed of the operator
+\verb@-@ and the literal \verb@1@.
\section{Operators}
@@ -323,7 +343,7 @@
< == > <= <> != >=
\end{verbatim}
-The comparison operators \verb\<>\ and \verb\!=\ are alternate
+The comparison operators \verb@<>@ and \verb@!=@ are alternate
spellings of the same operator.
\section{Delimiters}
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index 41ce234..5f9a0d8 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -44,7 +44,7 @@
files or windows. It is understood that these resources are freed
when the object is garbage-collected, but since garbage collection is
not guaranteed to happen, such objects also provide an explicit way to
-release the external resource, usually a \verb\close\ method.
+release the external resource, usually a \verb@close@ method.
Programs are strongly recommended to always explicitly close such
objects.
@@ -69,8 +69,8 @@
a = 1; b = 1; c = []; d = []
\end{verbatim}
-\verb\a\ and \verb\b\ may or may not refer to the same object with the
-value one, depending on the implementation, but \verb\c\ and \verb\d\
+\verb@a@ and \verb@b@ may or may not refer to the same object with the
+value one, depending on the implementation, but \verb@c@ and \verb@d@
are guaranteed to refer to two different, unique, newly created empty
lists.
@@ -90,9 +90,9 @@
`special attributes'. These are attributes that provide access to the
implementation and are not intended for general use. Their definition
may change in the future. There are also some `generic' special
-attributes, not listed with the individual objects: \verb\__methods__\
+attributes, not listed with the individual objects: \verb@__methods__@
is a list of the method names of a built-in object, if it has any;
-\verb\__members__\ is a list of the data attribute names of a built-in
+\verb@__members__@ is a list of the data attribute names of a built-in
object, if it has any.
\index{attribute}
\indexii{special}{attribute}
@@ -104,7 +104,7 @@
\item[None]
This type has a single value. There is a single object with this value.
-This object is accessed through the built-in name \verb\None\.
+This object is accessed through the built-in name \verb@None@.
It is returned from functions that don't explicitly return an object.
\ttindex{None}
\obindex{None@{\tt None}}
@@ -134,7 +134,7 @@
(The range may be larger on machines with a larger natural word
size, but not smaller.)
When the result of an operation falls outside this range, the
-exception \verb\OverflowError\ is raised.
+exception \verb@OverflowError@ is raised.
For the purpose of shift and mask operations, integers are assumed to
have a binary, 2's complement notation using 32 or more bits, and
hiding no bits from the user (i.e., all $2^{32}$ different bit
@@ -172,17 +172,17 @@
\item[Sequences]
These represent finite ordered sets indexed by natural numbers.
-The built-in function \verb\len()\ returns the number of elements
+The built-in function \verb@len()@ returns the number of elements
of a sequence. When this number is $n$, the index set contains
-the numbers $0, 1, \ldots, n-1$. Element \verb\i\ of sequence
-\verb\a\ is selected by \verb\a[i]\.
+the numbers $0, 1, \ldots, n-1$. Element \verb@i@ of sequence
+\verb@a@ is selected by \verb@a[i]@.
\obindex{seqence}
\bifuncindex{len}
\index{index operation}
\index{item selection}
\index{subscription}
-Sequences also support slicing: \verb\a[i:j]\ selects all elements
+Sequences also support slicing: \verb@a[i:j]@ selects all elements
with index $k$ such that $i <= k < j$. When used as an expression,
a slice is a sequence of the same type --- this implies that the
index set is renumbered so that it starts at 0 again.
@@ -209,7 +209,7 @@
The elements of a string are characters. There is no separate
character type; a character is represented by a string of one element.
Characters represent (at least) 8-bit bytes. The built-in
-functions \verb\chr()\ and \verb\ord()\ convert between characters
+functions \verb@chr()@ and \verb@ord()@ convert between characters
and nonnegative integers representing the byte values.
Bytes with the values 0-127 represent the corresponding ASCII values.
The string data type is also used to represent arrays of bytes, e.g.
@@ -223,7 +223,7 @@
(On systems whose native character set is not ASCII, strings may use
EBCDIC in their internal representation, provided the functions
-\verb\chr()\ and \verb\ord()\ implement a mapping between ASCII and
+\verb@chr()@ and \verb@ord()@ implement a mapping between ASCII and
EBCDIC, and string comparison preserves the ASCII order.
Or perhaps someone can propose a better rule?)
\index{ASCII}
@@ -250,7 +250,7 @@
\item[Mutable sequences]
Mutable sequences can be changed after they are created. The
subscription and slicing notations can be used as the target of
-assignment and \verb\del\ (delete) statements.
+assignment and \verb@del@ (delete) statements.
\obindex{mutable sequece}
\obindex{mutable}
\indexii{assignment}{statement}
@@ -276,10 +276,10 @@
\item[Mapping types]
These represent finite sets of objects indexed by arbitrary index sets.
-The subscript notation \verb\a[k]\ selects the element indexed
-by \verb\k\ from the mapping \verb\a\; this can be used in
-expressions and as the target of assignments or \verb\del\ statements.
-The built-in function \verb\len()\ returns the number of elements
+The subscript notation \verb@a[k]@ selects the element indexed
+by \verb@k@ from the mapping \verb@a@; this can be used in
+expressions and as the target of assignments or \verb@del@ statements.
+The built-in function \verb@len()@ returns the number of elements
in a mapping.
\bifuncindex{len}
\index{subscription}
@@ -299,7 +299,7 @@
comparison: if two numbers compare equal (e.g. 1 and 1.0) then they
can be used interchangeably to index the same dictionary entry.
-Dictionaries are mutable; they are created by the \verb\{...}\
+Dictionaries are mutable; they are created by the \verb@{...}@
notation (see section \ref{dict}).
\obindex{dictionary}
\obindex{mutable}
@@ -308,7 +308,7 @@
\item[Callable types]
These are the types to which the function call (invocation) operation,
-written as \verb\function(argument, argument, ...)\, can be applied:
+written as \verb@function(argument, argument, ...)@, can be applied:
\indexii{function}{call}
\index{invocation}
\indexii{function}{argument}
@@ -325,8 +325,8 @@
\obindex{function}
\obindex{user-defined function}
-Special read-only attributes: \verb\func_code\ is the code object
-representing the compiled function body, and \verb\func_globals\ is (a
+Special read-only attributes: \verb@func_code@ is the code object
+representing the compiled function body, and \verb@func_globals@ is (a
reference to) the dictionary that holds the function's global
variables --- it implements the global name space of the module in
which the function was defined.
@@ -346,14 +346,14 @@
\indexii{user-defined}{method}
\index{object closure}
-Special read-only attributes: \verb\im_self\ is the class instance
-object, \verb\im_func\ is the function object.
+Special read-only attributes: \verb@im_self@ is the class instance
+object, \verb@im_func@ is the function object.
\ttindex{im_func}
\ttindex{im_self}
\item[Built-in functions]
A built-in function object is a wrapper around a C function. Examples
-of built-in functions are \verb\len\ and \verb\math.sin\. There
+of built-in functions are \verb@len@ and \verb@math.sin@. There
are no special attributes. The number and type of the arguments are
determined by the C function.
\obindex{built-in function}
@@ -363,18 +363,20 @@
\item[Built-in methods]
This is really a different disguise of a built-in function, this time
containing an object passed to the C function as an implicit extra
-argument. An example of a built-in method is \verb\list.append\ if
-\verb\list\ is a list object.
+argument. An example of a built-in method is \verb@list.append@ if
+\verb@list@ is a list object.
\obindex{built-in method}
\obindex{method}
\indexii{built-in}{method}
\item[Classes]
Class objects are described below. When a class object is called as a
-parameterless function, a new class instance (also described below) is
-created and returned. The class's initialization function is not
-called --- this is the responsibility of the caller. It is illegal to
-call a class object with one or more arguments.
+function, a new class instance (also described below) is created and
+returned. This implies a call to the class's \verb@__init__@ method
+if it has one. Any arguments are passed on to the \verb@__init__@
+method -- if there is \verb@__init__@ method, the class must be called
+without arguments.
+\ttindex{__init__}
\obindex{class}
\obindex{class instance}
\obindex{instance}
@@ -383,10 +385,10 @@
\end{description}
\item[Modules]
-Modules are imported by the \verb\import\ statement (see section
+Modules are imported by the \verb@import@ statement (see section
\ref{import}). A module object is a container for a module's name
space, which is a dictionary (the same dictionary as referenced by the
-\verb\func_globals\ attribute of functions defined in the module).
+\verb@func_globals@ attribute of functions defined in the module).
Module attribute references are translated to lookups in this
dictionary. A module object does not contain the code object used to
initialize the module (since it isn't needed once the initialization
@@ -396,8 +398,8 @@
Attribute assignment update the module's name space dictionary.
-Special read-only attributes: \verb\__dict__\ yields the module's name
-space as a dictionary object; \verb\__name__\ yields the module's name
+Special read-only attributes: \verb@__dict__@ yields the module's name
+space as a dictionary object; \verb@__name__@ yields the module's name
as a string object.
\ttindex{__dict__}
\ttindex{__name__}
@@ -423,12 +425,12 @@
dictionary of a base class.
\indexiii{class}{attribute}{assignment}
-A class can be called as a parameterless function to yield a class
-instance (see above).
+A class can be called as a function to yield a class instance (see
+above).
\indexii{class object}{call}
-Special read-only attributes: \verb\__dict__\ yields the dictionary
-containing the class's name space; \verb\__bases__\ yields a tuple
+Special read-only attributes: \verb@__dict__@ yields the dictionary
+containing the class's name space; \verb@__bases__@ yields a tuple
(possibly empty or a singleton) containing the base classes, in the
order of their occurrence in the base class list.
\ttindex{__dict__}
@@ -436,7 +438,7 @@
\item[Class instances]
A class instance is created by calling a class object as a
-parameterless function. A class instance has a dictionary in which
+function. A class instance has a dictionary in which
attribute references are searched. When an attribute is not found
there, and the instance's class has an attribute by that name, and
that class attribute is a user-defined function (and in no other
@@ -457,17 +459,17 @@
\obindex{sequence}
\obindex{mapping}
-Special read-only attributes: \verb\__dict__\ yields the attribute
-dictionary; \verb\__class__\ yields the instance's class.
+Special read-only attributes: \verb@__dict__@ yields the attribute
+dictionary; \verb@__class__@ yields the instance's class.
\ttindex{__dict__}
\ttindex{__class__}
\item[Files]
A file object represents an open file. (It is a wrapper around a C
{\tt stdio} file pointer.) File objects are created by the
-\verb\open()\ built-in function, and also by \verb\posix.popen()\ and
-the \verb\makefile\ method of socket objects. \verb\sys.stdin\,
-\verb\sys.stdout\ and \verb\sys.stderr\ are file objects corresponding
+\verb@open()@ built-in function, and also by \verb@posix.popen()@ and
+the \verb@makefile@ method of socket objects. \verb@sys.stdin@,
+\verb@sys.stdout@ and \verb@sys.stderr@ are file objects corresponding
the the interpreter's standard input, output and error streams.
See the Python Library Reference for methods of file objects and other
details.
@@ -500,12 +502,12 @@
to execute a bare code object.
\obindex{code}
-Special read-only attributes: \verb\co_code\ is a string representing
-the sequence of instructions; \verb\co_consts\ is a list of literals
-used by the code; \verb\co_names\ is a list of names (strings) used by
-the code; \verb\co_filename\ is the filename from which the code was
+Special read-only attributes: \verb@co_code@ is a string representing
+the sequence of instructions; \verb@co_consts@ is a list of literals
+used by the code; \verb@co_names@ is a list of names (strings) used by
+the code; \verb@co_filename@ is the filename from which the code was
compiled. (To find out the line numbers, you would have to decode the
-instructions; the standard library module \verb\dis\ contains an
+instructions; the standard library module \verb@dis@ contains an
example of how to do this.)
\ttindex{co_code}
\ttindex{co_consts}
@@ -517,12 +519,12 @@
objects (see below).
\obindex{frame}
-Special read-only attributes: \verb\f_back\ is to the previous
-stack frame (towards the caller), or \verb\None\ if this is the bottom
-stack frame; \verb\f_code\ is the code object being executed in this
-frame; \verb\f_globals\ is the dictionary used to look up global
-variables; \verb\f_locals\ is used for local variables;
-\verb\f_lineno\ gives the line number and \verb\f_lasti\ gives the
+Special read-only attributes: \verb@f_back@ is to the previous
+stack frame (towards the caller), or \verb@None@ if this is the bottom
+stack frame; \verb@f_code@ is the code object being executed in this
+frame; \verb@f_globals@ is the dictionary used to look up global
+variables; \verb@f_locals@ is used for local variables;
+\verb@f_lineno@ gives the line number and \verb@f_lasti@ gives the
precise instruction (this is an index into the instruction string of
the code object).
\ttindex{f_back}
@@ -539,11 +541,11 @@
level a traceback object is inserted in front of the current
traceback. When an exception handler is entered
(see also section \ref{try}), the stack trace is
-made available to the program as \verb\sys.exc_traceback\. When the
+made available to the program as \verb@sys.exc_traceback@. When the
program contains no suitable handler, the stack trace is written
(nicely formatted) to the standard error stream; if the interpreter is
interactive, it is also made available to the user as
-\verb\sys.last_traceback\.
+\verb@sys.last_traceback@.
\obindex{traceback}
\indexii{stack}{trace}
\indexii{exception}{handler}
@@ -553,15 +555,15 @@
\ttindex{sys.exc_traceback}
\ttindex{sys.last_traceback}
-Special read-only attributes: \verb\tb_next\ is the next level in the
+Special read-only attributes: \verb@tb_next@ is the next level in the
stack trace (towards the frame where the exception occurred), or
-\verb\None\ if there is no next level; \verb\tb_frame\ points to the
-execution frame of the current level; \verb\tb_lineno\ gives the line
-number where the exception occurred; \verb\tb_lasti\ indicates the
+\verb@None@ if there is no next level; \verb@tb_frame@ points to the
+execution frame of the current level; \verb@tb_lineno@ gives the line
+number where the exception occurred; \verb@tb_lasti@ indicates the
precise instruction. The line number and last instruction in the
traceback may differ from the line number of its frame object if the
-exception occurred in a \verb\try\ statement with no matching
-\verb\except\ clause or with a \verb\finally\ clause.
+exception occurred in a \verb@try@ statement with no matching
+\verb@except@ clause or with a \verb@finally@ clause.
\ttindex{tb_next}
\ttindex{tb_frame}
\ttindex{tb_lineno}
@@ -578,17 +580,19 @@
A class can implement certain operations that are invoked by special
syntax (such as subscription or arithmetic operations) by defining
methods with special names. For instance, if a class defines a
-method named \verb\__getitem__\, and \verb\x\ is an instance of this
-class, then \verb\x[i]\ is equivalent to \verb\x.__getitem__(i)\.
-(The reverse is not true --- if \verb\x\ is a list object,
-\verb\x.__getitem__(i)\ is not equivalent to \verb\x[i]\.)
+method named \verb@__getitem__@, and \verb@x@ is an instance of this
+class, then \verb@x[i]@ is equivalent to \verb@x.__getitem__(i)@.
+(The reverse is not true --- if \verb@x@ is a list object,
+\verb@x.__getitem__(i)@ is not equivalent to \verb@x[i]@.)
-Except for \verb\__repr__\, \verb\__str__\ and \verb\__cmp__\,
+Except for \verb@__repr__@, \verb@__str__@ and \verb@__cmp__@,
attempts to execute an
operation raise an exception when no appropriate method is defined.
-For \verb\__repr__\ and \verb\__cmp__\, the traditional
-interpretations are used in this case.
-For \verb\__str__\, the \verb\__repr__\ method is used.
+For \verb@__repr__@, the default is to return a string describing the
+object's class and address.
+For \verb@__cmp__@, the default is to compare instances based on their
+address.
+For \verb@__str__@, the default is to use \verb@__repr__@.
\subsection{Special methods for any type}
@@ -614,17 +618,17 @@
the interpreter exits.
\item[\tt __repr__(self)]
-Called by the \verb\repr()\ built-in function and by conversions
+Called by the \verb@repr()@ built-in function and by conversions
(reverse quotes) to compute the string representation of an object.
\item[\tt __str__(self)]
-Called by the \verb\str()\ built-in function and by the \verb\print\
+Called by the \verb@str()@ built-in function and by the \verb@print@
statement compute the string representation of an object.
\item[\tt __cmp__(self, other)]
Called by all comparison operations. Should return -1 if
-\verb\self < other\, 0 if \verb\self == other\, +1 if
-\verb\self > other\. If no \code{__cmp__} operation is defined, class
+\verb@self < other@, 0 if \verb@self == other@, +1 if
+\verb@self > other@. If no \code{__cmp__} operation is defined, class
instances are compared by object identity (``address'').
(Implementation note: due to limitations in the interpreter,
exceptions raised by comparisons are ignored, and the objects will be
@@ -654,23 +658,23 @@
\begin{description}
\item[\tt __len__(self)]
-Called to implement the built-in function \verb\len()\. Should return
-the length of the object, an integer \verb\>=\ 0. Also, an object
-whose \verb\__len__()\ method returns 0 is considered to be false in a
+Called to implement the built-in function \verb@len()@. Should return
+the length of the object, an integer \verb@>=@ 0. Also, an object
+whose \verb@__len__()@ method returns 0 is considered to be false in a
Boolean context.
\item[\tt __getitem__(self, key)]
-Called to implement evaluation of \verb\self[key]\. Note that the
+Called to implement evaluation of \verb@self[key]@. Note that the
special interpretation of negative keys (if the class wishes to
-emulate a sequence type) is up to the \verb\__getitem__\ method.
+emulate a sequence type) is up to the \verb@__getitem__@ method.
\item[\tt __setitem__(self, key, value)]
-Called to implement assignment to \verb\self[key]\. Same note as for
-\verb\__getitem__\.
+Called to implement assignment to \verb@self[key]@. Same note as for
+\verb@__getitem__@.
\item[\tt __delitem__(self, key)]
-Called to implement deletion of \verb\self[key]\. Same note as for
-\verb\__getitem__\.
+Called to implement deletion of \verb@self[key]@. Same note as for
+\verb@__getitem__@.
\end{description}
@@ -680,19 +684,19 @@
\begin{description}
\item[\tt __getslice__(self, i, j)]
-Called to implement evaluation of \verb\self[i:j]\. Note that missing
-\verb\i\ or \verb\j\ are replaced by 0 or \verb\len(self)\,
-respectively, and \verb\len(self)\ has been added (once) to originally
-negative \verb\i\ or \verb\j\ by the time this function is called
-(unlike for \verb\__getitem__\).
+Called to implement evaluation of \verb@self[i:j]@. Note that missing
+\verb@i@ or \verb@j@ are replaced by 0 or \verb@len(self)@,
+respectively, and \verb@len(self)@ has been added (once) to originally
+negative \verb@i@ or \verb@j@ by the time this function is called
+(unlike for \verb@__getitem__@).
\item[\tt __setslice__(self, i, j, sequence)]
-Called to implement assignment to \verb\self[i:j]\. Same notes as for
-\verb\__getslice__\.
+Called to implement assignment to \verb@self[i:j]@. Same notes as for
+\verb@__getslice__@.
\item[\tt __delslice__(self, i, j)]
-Called to implement deletion of \verb\self[i:j]\. Same notes as for
-\verb\__getslice__\.
+Called to implement deletion of \verb@self[i:j]@. Same notes as for
+\verb@__getslice__@.
\end{description}
@@ -713,20 +717,20 @@
\item[\tt __and__(self, other)]\itemjoin
\item[\tt __xor__(self, other)]\itemjoin
\item[\tt __or__(self, other)]\itembreak
-Called to implement the binary arithmetic operations (\verb\+\,
-\verb\-\, \verb\*\, \verb\/\, \verb\%\, \verb\divmod()\, \verb\pow()\,
-\verb\<<\, \verb\>>\, \verb\&\, \verb\^\, \verb\|\).
+Called to implement the binary arithmetic operations (\verb@+@,
+\verb@-@, \verb@*@, \verb@/@, \verb@%@, \verb@divmod()@, \verb@pow()@,
+\verb@<<@, \verb@>>@, \verb@&@, \verb@^@, \verb@|@).
\item[\tt __neg__(self)]\itemjoin
\item[\tt __pos__(self)]\itemjoin
\item[\tt __abs__(self)]\itemjoin
\item[\tt __invert__(self)]\itembreak
-Called to implement the unary arithmetic operations (\verb\-\, \verb\+\,
-\verb\abs()\ and \verb\~\).
+Called to implement the unary arithmetic operations (\verb@-@, \verb@+@,
+\verb@abs()@ and \verb@~@).
\item[\tt __nonzero__(self)]
Called to implement boolean testing; should return 0 or 1. An
-alternative name for this method is \verb\__len__\.
+alternative name for this method is \verb@__len__@.
\item[\tt __coerce__(self, other)]
Called to implement ``mixed-mode'' numeric arithmetic. Should either
@@ -737,11 +741,11 @@
sometimes, if the implementation of the other type cannot be changed,
it is useful to do the conversion to the other type here).
-Note that this method is not called to coerce the arguments to \verb\+\
-and \verb\*\, because these are also used to implement sequence
+Note that this method is not called to coerce the arguments to \verb@+@
+and \verb@*@, because these are also used to implement sequence
concatenation and repetition, respectively. Also note that, for the
-same reason, in \verb\n*x\, where \verb\n\ is a built-in number and
-\verb\x\ is an instance, a call to \verb\x.__mul__(n)\ is made.%
+same reason, in \verb@n*x@, where \verb@n@ is a built-in number and
+\verb@x@ is an instance, a call to \verb@x.__mul__(n)@ is made.%
\footnote{The interpreter should really distinguish between
user-defined classes implementing sequences, mappings or numbers, but
currently it doesn't --- hence this strange exception.}
@@ -749,12 +753,12 @@
\item[\tt __int__(self)]\itemjoin
\item[\tt __long__(self)]\itemjoin
\item[\tt __float__(self)]\itembreak
-Called to implement the built-in functions \verb\int()\, \verb\long()\
-and \verb\float()\. Should return a value of the appropriate type.
+Called to implement the built-in functions \verb@int()@, \verb@long()@
+and \verb@float()@. Should return a value of the appropriate type.
\item[\tt __oct__(self)]\itemjoin
\item[\tt __hex__(self)]\itembreak
-Called to implement the built-in functions \verb\oct()\ and
-\verb\hex()\. Should return a string value.
+Called to implement the built-in functions \verb@oct()@ and
+\verb@hex()@. Should return a string value.
\end{description}
diff --git a/Doc/ref/ref4.tex b/Doc/ref/ref4.tex
index 62db120..c14fada 100644
--- a/Doc/ref/ref4.tex
+++ b/Doc/ref/ref4.tex
@@ -20,9 +20,9 @@
body is a code block. A class definition is a code block. Each
command typed interactively is a separate code block; a script file is
a code block. The string argument passed to the built-in function
-\verb\eval\ and to the \verb\exec\ statement are code blocks.
+\verb@eval@ and to the \verb@exec@ statement are code blocks.
And finally, the
-expression read and evaluated by the built-in function \verb\input\ is
+expression read and evaluated by the built-in function \verb@input@ is
a code block.
A code block is executed in an execution frame. An {\em execution
@@ -46,7 +46,7 @@
The {\em local name space} of an execution frame determines the default
place where names are defined and searched. The {\em global name
-space} determines the place where names listed in \verb\global\
+space} determines the place where names listed in \verb@global@
statements are defined and searched, and where names that are not
explicitly bound in the current code block are searched.
\indexii{local}{name space}
@@ -55,25 +55,35 @@
Whether a name is local or global in a code block is determined by
static inspection of the source text for the code block: in the
-absence of \verb\global\ statements, a name that is bound anywhere in
+absence of \verb@global@ statements, a name that is bound anywhere in
the code block is local in the entire code block; all other names are
-considered global. The \verb\global\ statement forces global
+considered global. The \verb@global@ statement forces global
interpretation of selected names throughout the code block. The
-following constructs bind names: formal parameters, \verb\import\
+following constructs bind names: formal parameters, \verb@import@
statements, class and function definitions (these bind the class or
function name), and targets that are identifiers if occurring in an
-assignment, \verb\for\ loop header, or \verb\except\ clause header.
-(A target occurring in a \verb\del\ statement does not bind a name.)
+assignment, \verb@for@ loop header, or \verb@except@ clause header.
+
+A target occurring in a \verb@del@ statement is also considered bound
+for this purpose (though the actual semantics are to ``unbind'' the
+name).
When a global name is not found in the global name space, it is
searched in the list of ``built-in'' names (which is actually the
-global name space of the module \verb\__builtin__\). When a name is not
-found at all, the \verb\NameError\ exception is raised.
+global name space of the module \verb@__builtin__@). When a name is not
+found at all, the \verb@NameError@ exception is raised.%
+\footnote{If the code block contains \verb@exec@ statement or the
+construct \verb@from ... import *@, the semantics of names not
+explicitly mentioned in a \verb@global@ statement change subtly: name
+lookup first searches the local name space, then the global one, then
+the built-in one.}
The following table lists the meaning of the local and global name
space for various types of code blocks. The name space for a
particular module is automatically created when the module is first
-referenced.
+referenced. Note that in almost all cases, the global name space is
+the name space of the containing module -- scopes in Python do not
+nest!
\begin{center}
\begin{tabular}{|l|l|l|l|}
@@ -81,15 +91,18 @@
Code block type & Global name space & Local name space & Notes \\
\hline
Module & n.s. for this module & same as global & \\
-Script & n.s. for \verb\__main__\ & same as global & \\
-Interactive command & n.s. for \verb\__main__\ & same as global & \\
+Script & n.s. for \verb@__main__@ & same as global & \\
+Interactive command & n.s. for \verb@__main__@ & same as global & \\
Class definition & global n.s. of containing block & new n.s. & \\
Function body & global n.s. of containing block & new n.s. & \\
-String passed to \verb\exec\ or \verb\eval\
+String passed to \verb@exec@ statement
+ & global n.s. of cobtaining block
+ & local n.s. of containing block & (1) \\
+String passed to \verb@eval()@
& global n.s. of caller & local n.s. of caller & (1) \\
-File read by \verb\execfile\
+File read by \verb@execfile()@
& global n.s. of caller & local n.s. of caller & (1) \\
-Expression read by \verb\input\
+Expression read by \verb@input@
& global n.s. of caller & local n.s. of caller & \\
\hline
\end{tabular}
@@ -101,7 +114,7 @@
\item[n.s.] means {\em name space}
-\item[(1)] The global and local name space for these functions can be
+\item[(1)] The global and local name space for these can be
overridden with optional extra arguments.
\end{description}
@@ -123,8 +136,8 @@
The Python interpreter raises an exception when it detects an run-time
error (such as division by zero). A Python program can also
-explicitly raise an exception with the \verb\raise\ statement.
-Exception handlers are specified with the \verb\try...except\
+explicitly raise an exception with the \verb@raise@ statement.
+Exception handlers are specified with the \verb@try...except@
statement.
Python uses the ``termination'' model of error handling: an exception
@@ -139,10 +152,10 @@
Exceptions are identified by string objects. Two different string
objects with the same value identify different exceptions.
-When an exception is raised, an object (maybe \verb\None\) is passed
+When an exception is raised, an object (maybe \verb@None@) is passed
as the exception's ``parameter''; this object does not affect the
selection of an exception handler, but is passed to the selected
exception handler as additional information.
-See also the description of the \verb\try\ and \verb\raise\
+See also the description of the \verb@try@ and \verb@raise@
statements.
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index 55f523f..3e60931 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -12,14 +12,14 @@
parentheses. The only places where expressions are used in the syntax
instead of conditions is in expression statements and on the
right-hand side of assignment statements; this catches some nasty bugs
-like accidentally writing \verb\x == 1\ instead of \verb\x = 1\.
+like accidentally writing \verb@x == 1@ instead of \verb@x = 1@.
\indexii{assignment}{statement}
The comma plays several roles in Python's syntax. It is usually an
operator with a lower precedence than all others, but occasionally
serves other purposes as well; e.g. it separates function arguments,
is used in list and dictionary constructors, and has special semantics
-in \verb\print\ statements.
+in \verb@print@ statements.
\index{comma}
When (one alternative of) a syntax rule has the form
@@ -28,8 +28,8 @@
name: othername
\end{verbatim}
-and no semantics are given, the semantics of this form of \verb\name\
-are the same as for \verb\othername\.
+and no semantics are given, the semantics of this form of \verb@name@
+are the same as for \verb@othername@.
\index{syntax}
\section{Arithmetic conversions}
@@ -38,7 +38,7 @@
When a description of an arithmetic operator below uses the phrase
``the numeric arguments are converted to a common type'',
this both means that if either argument is not a number, a
-\verb\TypeError\ exception is raised, and that otherwise
+\verb@TypeError@ exception is raised, and that otherwise
the following conversions are applied:
\exindex{TypeError}
\indexii{floating point}{number}
@@ -71,11 +71,13 @@
\index{identifier}
An identifier occurring as an atom is a reference to a local, global
-or built-in name binding. If a name can be assigned to anywhere in a
-code block, and is not mentioned in a \verb\global\ statement in that
-code block, it refers to a local name throughout that code block.
-Otherwise, it refers to a global name if one exists, else to a
-built-in name.
+or built-in name binding. If a name is assigned to anywhere in a code
+block (even in unreachable code), and is not mentioned in a
+\verb@global@ statement in that code block, then it refers to a local
+name throughout that code block. When it is not assigned to anywhere
+in the block, or when it is assigned to but also explicitly listed in
+a \verb@global@ statement, it refers to a global name if one exists,
+else to a built-in name (and this binding may dynamically change).
\indexii{name}{binding}
\index{code block}
\stindex{global}
@@ -84,7 +86,7 @@
When the name is bound to an object, evaluation of the atom yields
that object. When a name is not bound, an attempt to evaluate it
-raises a \verb\NameError\ exception.
+raises a \verb@NameError@ exception.
\exindex{NameError}
\subsection{Literals}
@@ -197,10 +199,10 @@
converts the resulting object into a string according to rules
specific to its type.
-If the object is a string, a number, \verb\None\, or a tuple, list or
+If the object is a string, a number, \verb@None@, or a tuple, list or
dictionary containing only objects whose type is one of these, the
resulting string is a valid Python expression which can be passed to
-the built-in function \verb\eval()\ to yield an expression with the
+the built-in function \verb@eval()@ to yield an expression with the
same value (or an approximation, if floating point numbers are
involved).
@@ -234,7 +236,7 @@
The primary must evaluate to an object of a type that supports
attribute references, e.g. a module or a list. This object is then
asked to produce the attribute whose name is the identifier. If this
-attribute is not available, the exception \verb\AttributeError\ is
+attribute is not available, the exception \verb@AttributeError@ is
raised. Otherwise, the type and value of the object produced is
determined by the object. Multiple evaluations of the same attribute
reference may yield different objects.
@@ -266,7 +268,7 @@
If it is a sequence, the condition must evaluate to a plain integer.
If this value is negative, the length of the sequence is added to it
-(so that, e.g. \verb\x[-1]\ selects the last item of \verb\x\.)
+(so that, e.g. \verb@x[-1]@ selects the last item of \verb@x@.)
The resulting value must be a nonnegative integer smaller than the
number of items in the sequence, and the subscription selects the item
whose index is that value (counting from zero).
@@ -318,7 +320,7 @@
class, the argument list must be empty; otherwise, the arguments are
evaluated.
-A call always returns some value, possibly \verb\None\, unless it
+A call always returns some value, possibly \verb@None@, unless it
raises an exception. How this value is computed depends on the type
of the callable object. If it is:
@@ -328,7 +330,7 @@
executed, passing it the argument list. The first thing the code
block will do is bind the formal parameters to the arguments; this is
described in section \ref{function}. When the code block executes a
-\verb\return\ statement, this specifies the return value of the
+\verb@return@ statement, this specifies the return value of the
function call.
\indexii{function}{call}
\indexiii{user-defined}{function}{call}
@@ -371,22 +373,22 @@
u_expr: primary | "-" u_expr | "+" u_expr | "~" u_expr
\end{verbatim}
-The unary \verb\"-"\ (minus) operator yields the negation of its
+The unary \verb@"-"@ (minus) operator yields the negation of its
numeric argument.
\index{negation}
\index{minus}
-The unary \verb\"+"\ (plus) operator yields its numeric argument
+The unary \verb@"+"@ (plus) operator yields its numeric argument
unchanged.
\index{plus}
-The unary \verb\"~"\ (invert) operator yields the bit-wise inversion
+The unary \verb@"~"@ (invert) operator yields the bit-wise inversion
of its plain or long integer argument. The bit-wise inversion of
-\verb\x\ is defined as \verb\-(x+1)\.
+\verb@x@ is defined as \verb@-(x+1)@.
\index{inversion}
In all three cases, if the argument does not have the proper type,
-a \verb\TypeError\ exception is raised.
+a \verb@TypeError@ exception is raised.
\exindex{TypeError}
\section{Binary arithmetic operations}
@@ -404,7 +406,7 @@
a_expr: m_expr | aexpr "+" m_expr | aexpr "-" m_expr
\end{verbatim}
-The \verb\"*"\ (multiplication) operator yields the product of its
+The \verb@"*"@ (multiplication) operator yields the product of its
arguments. The arguments must either both be numbers, or one argument
must be a plain integer and the other must be a sequence. In the
former case, the numbers are converted to a common type and then
@@ -412,40 +414,40 @@
performed; a negative repetition factor yields an empty sequence.
\index{multiplication}
-The \verb\"/"\ (division) operator yields the quotient of its
+The \verb@"/"@ (division) operator yields the quotient of its
arguments. The numeric arguments are first converted to a common
type. Plain or long integer division yields an integer of the same
type; the result is that of mathematical division with the `floor'
function applied to the result. Division by zero raises the
-\verb\ZeroDivisionError\ exception.
+\verb@ZeroDivisionError@ exception.
\exindex{ZeroDivisionError}
\index{division}
-The \verb\"%"\ (modulo) operator yields the remainder from the
+The \verb@"%"@ (modulo) operator yields the remainder from the
division of the first argument by the second. The numeric arguments
are first converted to a common type. A zero right argument raises
-the \verb\ZeroDivisionError\ exception. The arguments may be floating
-point numbers, e.g. \verb\3.14 % 0.7\ equals \verb\0.34\. The modulo
+the \verb@ZeroDivisionError@ exception. The arguments may be floating
+point numbers, e.g. \verb@3.14 % 0.7@ equals \verb@0.34@. The modulo
operator always yields a result with the same sign as its second
operand (or zero); the absolute value of the result is strictly
smaller than the second operand.
\index{modulo}
The integer division and modulo operators are connected by the
-following identity: \verb\x == (x/y)*y + (x%y)\. Integer division and
-modulo are also connected with the built-in function \verb\divmod()\:
-\verb\divmod(x, y) == (x/y, x%y)\. These identities don't hold for
+following identity: \verb@x == (x/y)*y + (x%y)@. Integer division and
+modulo are also connected with the built-in function \verb@divmod()@:
+\verb@divmod(x, y) == (x/y, x%y)@. These identities don't hold for
floating point numbers; there a similar identity holds where
-\verb\x/y\ is replaced by \verb\floor(x/y)\).
+\verb@x/y@ is replaced by \verb@floor(x/y)@).
-The \verb\"+"\ (addition) operator yields the sum of its arguments.
+The \verb@"+"@ (addition) operator yields the sum of its arguments.
The arguments must either both be numbers, or both sequences of the
same type. In the former case, the numbers are converted to a common
type and then added together. In the latter case, the sequences are
concatenated.
\index{addition}
-The \verb\"-"\ (subtraction) operator yields the difference of its
+The \verb@"-"@ (subtraction) operator yields the difference of its
arguments. The numeric arguments are first converted to a common
type.
\index{subtraction}
@@ -470,7 +472,7 @@
integers there is no overflow check so this drops bits and flip the
sign if the result is not less than $2^{31}$ in absolute value.
-Negative shift counts raise a \verb\ValueError\ exception.
+Negative shift counts raise a \verb@ValueError@ exception.
\exindex{ValueError}
\section{Binary bit-wise operations}
@@ -484,18 +486,18 @@
or_expr: xor_expr | or_expr "|" xor_expr
\end{verbatim}
-The \verb\"&"\ operator yields the bitwise AND of its arguments, which
+The \verb@"&"@ operator yields the bitwise AND of its arguments, which
must be plain or long integers. The arguments are converted to a
common type.
\indexii{bit-wise}{and}
-The \verb\"^"\ operator yields the bitwise XOR (exclusive OR) of its
+The \verb@"^"@ operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be plain or long integers. The arguments are
converted to a common type.
\indexii{bit-wise}{xor}
\indexii{exclusive}{or}
-The \verb\"|"\ operator yields the bitwise (inclusive) OR of its
+The \verb@"|"@ operator yields the bitwise (inclusive) OR of its
arguments, which must be plain or long integers. The arguments are
converted to a common type.
\indexii{bit-wise}{or}
@@ -507,7 +509,7 @@
Contrary to C, all comparison operations in Python have the same
priority, which is lower than that of any arithmetic, shifting or
bitwise operation. Also contrary to C, expressions like
-\verb\a < b < c\ have the interpretation that is conventional in
+\verb@a < b < c@ have the interpretation that is conventional in
mathematics:
\index{C}
@@ -519,23 +521,23 @@
Comparisons yield integer values: 1 for true, 0 for false.
Comparisons can be chained arbitrarily, e.g. $x < y <= z$ is
-equivalent to $x < y$ \verb\and\ $y <= z$, except that $y$ is
+equivalent to $x < y$ \verb@and@ $y <= z$, except that $y$ is
evaluated only once (but in both cases $z$ is not evaluated at all
when $x < y$ is found to be false).
\indexii{chaining}{comparisons}
\catcode`\_=8
Formally, $e_0 op_1 e_1 op_2 e_2 ...e_{n-1} op_n e_n$ is equivalent to
-$e_0 op_1 e_1$ \verb\and\ $e_1 op_2 e_2$ \verb\and\ ... \verb\and\
+$e_0 op_1 e_1$ \verb@and@ $e_1 op_2 e_2$ \verb@and@ ... \verb@and@
$e_{n-1} op_n e_n$, except that each expression is evaluated at most once.
Note that $e_0 op_1 e_1 op_2 e_2$ does not imply any kind of comparison
between $e_0$ and $e_2$, e.g. $x < y > z$ is perfectly legal.
\catcode`\_=12
-The forms \verb\<>\ and \verb\!=\ are equivalent; for consistency with
-C, \verb\!=\ is preferred; where \verb\!=\ is mentioned below
-\verb\<>\ is also implied.
+The forms \verb@<>@ and \verb@!=@ are equivalent; for consistency with
+C, \verb@!=@ is preferred; where \verb@!=@ is mentioned below
+\verb@<>@ is also implied.
The operators {\tt "<", ">", "==", ">=", "<="}, and {\tt "!="} compare
the values of two objects. The objects needn't have the same type.
@@ -544,8 +546,8 @@
ordered consistently but arbitrarily.
(This unusual definition of comparison is done to simplify the
-definition of operations like sorting and the \verb\in\ and \verb\not
-in\ operators.)
+definition of operations like sorting and the \verb@in@ and
+\verb@not in@ operators.)
Comparison of objects of the same type depends on the type:
@@ -556,7 +558,7 @@
\item
Strings are compared lexicographically using the numeric equivalents
-(the result of the built-in function \verb\ord\) of their characters.
+(the result of the built-in function \verb@ord@) of their characters.
\item
Tuples and lists are compared lexicographically using comparison of
@@ -579,11 +581,11 @@
\end{itemize}
-The operators \verb\in\ and \verb\not in\ test for sequence
-membership: if $y$ is a sequence, $x ~\verb\in\~ y$ is true if and
+The operators \verb@in@ and \verb@not in@ test for sequence
+membership: if $y$ is a sequence, $x ~\verb@in@~ y$ is true if and
only if there exists an index $i$ such that $x = y[i]$.
-$x ~\verb\not in\~ y$ yields the inverse truth value. The exception
-\verb\TypeError\ is raised when $y$ is not a sequence, or when $y$ is
+$x ~\verb@not in@~ y$ yields the inverse truth value. The exception
+\verb@TypeError@ is raised when $y$ is not a sequence, or when $y$ is
a string and $x$ is not a string of length one.%
\footnote{The latter restriction is sometimes a nuisance.}
\opindex{in}
@@ -591,9 +593,9 @@
\indexii{membership}{test}
\obindex{sequence}
-The operators \verb\is\ and \verb\is not\ test for object identity:
-$x ~\verb\is\~ y$ is true if and only if $x$ and $y$ are the same
-object. $x ~\verb\is not\~ y$ yields the inverse truth value.
+The operators \verb@is@ and \verb@is not@ test for object identity:
+$x ~\verb@is@~ y$ is true if and only if $x$ and $y$ are the same
+object. $x ~\verb@is not@~ y$ yields the inverse truth value.
\opindex{is}
\opindex{is not}
\indexii{identity}{test}
@@ -613,38 +615,39 @@
In the context of Boolean operations, and also when conditions are
used by control flow statements, the following values are interpreted
-as false: \verb\None\, numeric zero of all types, empty sequences
+as false: \verb@None@, numeric zero of all types, empty sequences
(strings, tuples and lists), and empty mappings (dictionaries). All
other values are interpreted as true.
-The operator \verb\not\ yields 1 if its argument is false, 0 otherwise.
+The operator \verb@not@ yields 1 if its argument is false, 0 otherwise.
\opindex{not}
-The condition $x ~\verb\and\~ y$ first evaluates $x$; if $x$ is false,
+The condition $x ~\verb@and@~ y$ first evaluates $x$; if $x$ is false,
its value is returned; otherwise, $y$ is evaluated and the resulting
value is returned.
\opindex{and}
-The condition $x ~\verb\or\~ y$ first evaluates $x$; if $x$ is true,
+The condition $x ~\verb@or@~ y$ first evaluates $x$; if $x$ is true,
its value is returned; otherwise, $y$ is evaluated and the resulting
value is returned.
\opindex{or}
-(Note that \verb\and\ and \verb\or\ do not restrict the value and type
+(Note that \verb@and@ and \verb@or@ do not restrict the value and type
they return to 0 and 1, but rather return the last evaluated argument.
-This is sometimes useful, e.g. if \verb\s\ is a string that should be
+This is sometimes useful, e.g. if \verb@s@ is a string that should be
replaced by a default value if it is empty, the expression
-\verb\s or 'foo'\ yields the desired value. Because \verb\not\ has to
+\verb@s or 'foo'@ yields the desired value. Because \verb@not@ has to
invent a value anyway, it does not bother to return a value of the
-same type as its argument, so e.g. \verb\not 'foo'\ yields \verb\0\,
-not \verb\''\.)
+same type as its argument, so e.g. \verb@not 'foo'@ yields \verb@0@,
+not \verb@''@.)
Lambda forms (lambda expressions) have the same syntactic position as
conditions. They are a shorthand to create anonymous functions; the
-expression \verb\lambda\ {\em arguments}\verb\:\ {\em condition}
+expression {\em {\tt lambda} arguments{\tt :} condition}
yields a function object that behaves virtually identical to one
-defined with \verb\def\ {\em name}\verb\(\{\em arguments}\verb\) :
-return\ {\em condition}. See section \ref{function} for the syntax of
+defined with
+{\em {\tt def} name {\tt (}arguments{\tt ): return} condition}.
+See section \ref{function} for the syntax of
parameter lists. Note that functions created with lambda forms cannot
contain statements.
\label{lambda}
@@ -686,4 +689,4 @@
\indexii{trailing}{comma}
(To create an empty tuple, use an empty pair of parentheses:
-\verb\()\.)
+\verb@()@.)