mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Typo: "Otherwose" --> "Otherwise" (reported by Joakim Sernbrant
<joakim.sernbrant@front.se>). Misc. small fixes to the logical markup.
This commit is contained in:
parent
79d41ccdd3
commit
011f6fca31
1 changed files with 29 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
\chapter{Simple statements\label{simple}}
|
\chapter{Simple statements \label{simple}}
|
||||||
\indexii{simple}{statement}
|
\indexii{simple}{statement}
|
||||||
|
|
||||||
Simple statements are comprised within a single logical line.
|
Simple statements are comprised within a single logical line.
|
||||||
|
|
@ -21,7 +21,7 @@ simple_stmt: expression_stmt
|
||||||
| exec_stmt
|
| exec_stmt
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\section{Expression statements\label{exprstmts}}
|
\section{Expression statements \label{exprstmts}}
|
||||||
\indexii{expression}{statement}
|
\indexii{expression}{statement}
|
||||||
|
|
||||||
Expression statements are used (mostly interactively) to compute and
|
Expression statements are used (mostly interactively) to compute and
|
||||||
|
|
@ -51,23 +51,23 @@ any output.)
|
||||||
\indexii{writing}{values}
|
\indexii{writing}{values}
|
||||||
\indexii{procedure}{call}
|
\indexii{procedure}{call}
|
||||||
|
|
||||||
\section{Assert statements\label{assert}}\stindex{assert}
|
\section{Assert statements \label{assert}}
|
||||||
|
|
||||||
Assert statements are a convenient way to insert debugging
|
Assert statements\stindex{assert} are a convenient way to insert
|
||||||
assertions\indexii{debugging}{assertions} into a program:
|
debugging assertions\indexii{debugging}{assertions} into a program:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
assert_statement: "assert" expression ["," expression]
|
assert_statement: "assert" expression ["," expression]
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The simple form, ``\code{assert expression}'', is equivalent to
|
The simple form, \samp{assert expression}, is equivalent to
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
if __debug__:
|
if __debug__:
|
||||||
if not expression: raise AssertionError
|
if not expression: raise AssertionError
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The extended form, ``\code{assert expression1, expression2}'', is
|
The extended form, \samp{assert expression1, expression2}, is
|
||||||
equivalent to
|
equivalent to
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -76,7 +76,7 @@ if __debug__:
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
These equivalences assume that \code{__debug__}\ttindex{__debug__} and
|
These equivalences assume that \code{__debug__}\ttindex{__debug__} and
|
||||||
\code{AssertionError}\exindex{AssertionError} refer to the built-in
|
\exception{AssertionError}\exindex{AssertionError} refer to the built-in
|
||||||
variables with those names. In the current implementation, the
|
variables with those names. In the current implementation, the
|
||||||
built-in variable \code{__debug__} is 1 under normal circumstances, 0
|
built-in variable \code{__debug__} is 1 under normal circumstances, 0
|
||||||
when optimization is requested (command line option -O). The current
|
when optimization is requested (command line option -O). The current
|
||||||
|
|
@ -86,11 +86,11 @@ the source code for the expression that failed in the error message;
|
||||||
it will be displayed as part of the stack trace.
|
it will be displayed as part of the stack trace.
|
||||||
|
|
||||||
|
|
||||||
\section{Assignment statements\label{assignment}}
|
\section{Assignment statements \label{assignment}}
|
||||||
\indexii{assignment}{statement}
|
|
||||||
|
|
||||||
Assignment statements are used to (re)bind names to values and to
|
Assignment statements\indexii{assignment}{statement} are used to
|
||||||
modify attributes or items of mutable objects:
|
(re)bind names to values and to modify attributes or items of mutable
|
||||||
|
objects:
|
||||||
\indexii{binding}{name}
|
\indexii{binding}{name}
|
||||||
\indexii{rebinding}{name}
|
\indexii{rebinding}{name}
|
||||||
\obindex{mutable}
|
\obindex{mutable}
|
||||||
|
|
@ -137,7 +137,7 @@ must be a sequence with the same number of items as the there are
|
||||||
targets in the target list, and the items are assigned, from left to
|
targets in the target list, and the items are assigned, from left to
|
||||||
right, to the corresponding targets. (This rule is relaxed as of
|
right, to the corresponding targets. (This rule is relaxed as of
|
||||||
Python 1.5; in earlier versions, the object had to be a tuple. Since
|
Python 1.5; in earlier versions, the object had to be a tuple. Since
|
||||||
strings are sequences, an assignment like ``\code{a, b = "xy"}'' is
|
strings are sequences, an assignment like \samp{a, b = "xy"} is
|
||||||
now legal as long as the string has the right length.)
|
now legal as long as the string has the right length.)
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
@ -235,9 +235,9 @@ messages.)
|
||||||
|
|
||||||
WARNING: Although the definition of assignment implies that overlaps
|
WARNING: Although the definition of assignment implies that overlaps
|
||||||
between the left-hand side and the right-hand side are `safe' (e.g.,
|
between the left-hand side and the right-hand side are `safe' (e.g.,
|
||||||
``\code{a, b = b, a}'' swaps two variables), overlaps \emph{within} the
|
\samp{a, b = b, a} swaps two variables), overlaps \emph{within} the
|
||||||
collection of assigned-to variables are not safe! For instance, the
|
collection of assigned-to variables are not safe! For instance, the
|
||||||
following program prints ``\code{[0, 2]}'':
|
following program prints \samp{[0, 2]}:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
x = [0, 1]
|
x = [0, 1]
|
||||||
|
|
@ -247,7 +247,7 @@ print x
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
\section{The \keyword{pass} statement\label{pass}}
|
\section{The \keyword{pass} statement \label{pass}}
|
||||||
\stindex{pass}
|
\stindex{pass}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -265,7 +265,7 @@ def f(arg): pass # a function that does nothing (yet)
|
||||||
class C: pass # a class with no methods (yet)
|
class C: pass # a class with no methods (yet)
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\section{The \keyword{del} statement\label{del}}
|
\section{The \keyword{del} statement \label{del}}
|
||||||
\stindex{del}
|
\stindex{del}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -293,7 +293,7 @@ is in general equivalent to assignment of an empty slice of the
|
||||||
right type (but even this is determined by the sliced object).
|
right type (but even this is determined by the sliced object).
|
||||||
\indexii{attribute}{deletion}
|
\indexii{attribute}{deletion}
|
||||||
|
|
||||||
\section{The \keyword{print} statement\label{print}}
|
\section{The \keyword{print} statement \label{print}}
|
||||||
\stindex{print}
|
\stindex{print}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -330,7 +330,7 @@ exception is raised.
|
||||||
\withsubitem{(in module sys)}{\ttindex{stdout}}
|
\withsubitem{(in module sys)}{\ttindex{stdout}}
|
||||||
\exindex{RuntimeError}
|
\exindex{RuntimeError}
|
||||||
|
|
||||||
\section{The \keyword{return} statement\label{return}}
|
\section{The \keyword{return} statement \label{return}}
|
||||||
\stindex{return}
|
\stindex{return}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -353,7 +353,7 @@ with a \keyword{finally} clause, that \keyword{finally} clause is executed
|
||||||
before really leaving the function.
|
before really leaving the function.
|
||||||
\kwindex{finally}
|
\kwindex{finally}
|
||||||
|
|
||||||
\section{The \keyword{raise} statement\label{raise}}
|
\section{The \keyword{raise} statement \label{raise}}
|
||||||
\stindex{raise}
|
\stindex{raise}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -363,7 +363,7 @@ raise_stmt: "raise" [expression ["," expression ["," expression]]]
|
||||||
If no expressions are present, \keyword{raise} re-raises the last
|
If no expressions are present, \keyword{raise} re-raises the last
|
||||||
expression that was raised in the current scope.
|
expression that was raised in the current scope.
|
||||||
|
|
||||||
Otherwose, \keyword{raise} evaluates its first expression, which must yield
|
Otherwise, \keyword{raise} evaluates its first expression, which must yield
|
||||||
a string, class, or instance object. If there is a second expression,
|
a string, class, or instance object. If there is a second expression,
|
||||||
this is evaluated, else \code{None} is substituted. If the first
|
this is evaluated, else \code{None} is substituted. If the first
|
||||||
expression is a class object, then the second expression may be an
|
expression is a class object, then the second expression may be an
|
||||||
|
|
@ -393,7 +393,7 @@ exception occurred. This is useful to re-raise an exception
|
||||||
transparently in an except clause.
|
transparently in an except clause.
|
||||||
\obindex{traceback}
|
\obindex{traceback}
|
||||||
|
|
||||||
\section{The \keyword{break} statement\label{break}}
|
\section{The \keyword{break} statement \label{break}}
|
||||||
\stindex{break}
|
\stindex{break}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -420,7 +420,7 @@ with a \keyword{finally} clause, that \keyword{finally} clause is executed
|
||||||
before really leaving the loop.
|
before really leaving the loop.
|
||||||
\kwindex{finally}
|
\kwindex{finally}
|
||||||
|
|
||||||
\section{The \keyword{continue} statement\label{continue}}
|
\section{The \keyword{continue} statement \label{continue}}
|
||||||
\stindex{continue}
|
\stindex{continue}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -439,7 +439,7 @@ It continues with the next cycle of the nearest enclosing loop.
|
||||||
\indexii{loop}{statement}
|
\indexii{loop}{statement}
|
||||||
\kwindex{finally}
|
\kwindex{finally}
|
||||||
|
|
||||||
\section{The \keyword{import} statement\label{import}}
|
\section{The \keyword{import} statement \label{import}}
|
||||||
\stindex{import}
|
\stindex{import}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -501,8 +501,8 @@ module name: it goes through the list of identifiers, looks each one
|
||||||
of them up in the module found in step (1), and binds the name in the
|
of them up in the module found in step (1), and binds the name in the
|
||||||
local namespace to the object thus found. If a name is not found,
|
local namespace to the object thus found. If a name is not found,
|
||||||
\exception{ImportError} is raised. If the list of identifiers is replaced
|
\exception{ImportError} is raised. If the list of identifiers is replaced
|
||||||
by a star (\code{*}), all names defined in the module are bound,
|
by a star (\samp{*}), all names defined in the module are bound,
|
||||||
except those beginning with an underscore(\code{_}).
|
except those beginning with an underscore (\character{_}).
|
||||||
\indexii{name}{binding}
|
\indexii{name}{binding}
|
||||||
\exindex{ImportError}
|
\exindex{ImportError}
|
||||||
|
|
||||||
|
|
@ -510,7 +510,7 @@ Names bound by \keyword{import} statements may not occur in
|
||||||
\keyword{global} statements in the same scope.
|
\keyword{global} statements in the same scope.
|
||||||
\stindex{global}
|
\stindex{global}
|
||||||
|
|
||||||
The \keyword{from} form with \code{*} may only occur in a module scope.
|
The \keyword{from} form with \samp{*} may only occur in a module scope.
|
||||||
\kwindex{from}
|
\kwindex{from}
|
||||||
\stindex{from}
|
\stindex{from}
|
||||||
|
|
||||||
|
|
@ -534,7 +534,7 @@ about how the module search works from inside a package.]
|
||||||
[XXX Also should mention __import__().]
|
[XXX Also should mention __import__().]
|
||||||
\bifuncindex{__import__}
|
\bifuncindex{__import__}
|
||||||
|
|
||||||
\section{The \keyword{global} statement\label{global}}
|
\section{The \keyword{global} statement \label{global}}
|
||||||
\stindex{global}
|
\stindex{global}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
@ -574,7 +574,7 @@ containing the \keyword{exec} statement. The same applies to the
|
||||||
\bifuncindex{execfile}
|
\bifuncindex{execfile}
|
||||||
\bifuncindex{compile}
|
\bifuncindex{compile}
|
||||||
|
|
||||||
\section{The \keyword{exec} statement\label{exec}}
|
\section{The \keyword{exec} statement \label{exec}}
|
||||||
\stindex{exec}
|
\stindex{exec}
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue