replace vars() with locals() and globals(); 3rd raise arg; typos

This commit is contained in:
Guido van Rossum 1995-07-07 23:06:33 +00:00
parent 8fd02194c5
commit 611be707c2
4 changed files with 56 additions and 38 deletions

View File

@ -125,13 +125,14 @@ overridden with optional extra arguments.
\end{description} \end{description}
The built-in function \verb@vars()@ returns a dictionary representing The built-in functions \verb@globals()@ and \verb@locals()@ returns a
the current local name space. The effect of modifications to this dictionary representing the current global and local name space,
dictionary on the name space are undefined.% respectively. The effect of modifications to this dictionary on the
\footnote{The current implementation returns the dictionary actually name space are undefined.%
\footnote{The current implementations return the dictionary actually
used to implement the name space, {\em except} for functions, where used to implement the name space, {\em except} for functions, where
the optimizer may cause the local name space to be implemented the optimizer may cause the local name space to be implemented
differently.} differently, and \verb@locals()@ returns a read-only dictionary.}
\section{Exceptions} \section{Exceptions}

View File

@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
\verb@None@): \verb@None@):
\begin{verbatim} \begin{verbatim}
expression_stmt: expression_list expression_stmt: condition_list
\end{verbatim} \end{verbatim}
An expression statement evaluates the expression list (which may be a An expression statement evaluates the condition list (which may be a
single expression). If the value is not \verb@None@, it is converted single condition).
\indexii{expression}{list}
In interactive mode, if the value is not \verb@None@, it is converted
to a string using the rules for string conversions (expressions in to a string using the rules for string conversions (expressions in
reverse quotes), and the resulting string is written to standard reverse quotes), and the resulting string is written to standard
output (see section \ref{print}) on a line by itself. output (see section \ref{print}) on a line by itself.
\indexii{expression}{list} (The exception for \verb@None@ is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.)
\ttindex{None} \ttindex{None}
\indexii{string}{conversion} \indexii{string}{conversion}
\index{output} \index{output}
\indexii{standard}{output} \indexii{standard}{output}
\indexii{writing}{values} \indexii{writing}{values}
(The exception for \verb@None@ is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.
A tuple with only \verb@None@ items is written normally.)
\indexii{procedure}{call} \indexii{procedure}{call}
\section{Assignment statements} \section{Assignment statements}
@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
\begin{verbatim} \begin{verbatim}
def f(arg): pass # a function that does nothing (yet) def f(arg): pass # a function that does nothing (yet)
class C: pass # an class with no methods (yet) class C: pass # a class with no methods (yet)
\end{verbatim} \end{verbatim}
\section{The {\tt del} statement} \section{The {\tt del} statement}
@ -320,7 +320,7 @@ before really leaving the function.
\stindex{raise} \stindex{raise}
\begin{verbatim} \begin{verbatim}
raise_stmt: "raise" condition ["," condition] raise_stmt: "raise" condition ["," condition ["," condition]]
\end{verbatim} \end{verbatim}
\verb@raise@ evaluates its first condition, which must yield \verb@raise@ evaluates its first condition, which must yield
@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
identified by the first object, with the second one (or \verb@None@) identified by the first object, with the second one (or \verb@None@)
as its parameter. If the first object is an instance, it raises the as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as exception identified by the class of the object, with the instance as
its parameter. its parameter (and there should be no second object, or the second
object should be \verb@None@).
If a third object is present, and it it not \verb@None@, it should be
a traceback object (see section \ref{traceback}), and it is
substituted instead of the current location as the place where the
exception occurred. This is useful to re-raise an exception
transparently in an except clause.
\obindex{traceback}
\section{The {\tt break} statement} \section{The {\tt break} statement}
\stindex{break} \stindex{break}
@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
variables, respectively. variables, respectively.
Hints: dynamic evaluation of expressions is supported by the built-in Hints: dynamic evaluation of expressions is supported by the built-in
function \verb@eval()@. The built-in function \verb@vars()@ returns function \verb@eval()@. The built-in functions \verb@globals()@ and
the current local dictionary, which may be useful to pass around for \verb@locals()@ return the current global and local dictionary,
use by \verb@exec@. respectively, which may be useful to pass around for use by \verb@exec@.

View File

@ -125,13 +125,14 @@ overridden with optional extra arguments.
\end{description} \end{description}
The built-in function \verb@vars()@ returns a dictionary representing The built-in functions \verb@globals()@ and \verb@locals()@ returns a
the current local name space. The effect of modifications to this dictionary representing the current global and local name space,
dictionary on the name space are undefined.% respectively. The effect of modifications to this dictionary on the
\footnote{The current implementation returns the dictionary actually name space are undefined.%
\footnote{The current implementations return the dictionary actually
used to implement the name space, {\em except} for functions, where used to implement the name space, {\em except} for functions, where
the optimizer may cause the local name space to be implemented the optimizer may cause the local name space to be implemented
differently.} differently, and \verb@locals()@ returns a read-only dictionary.}
\section{Exceptions} \section{Exceptions}

View File

@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
\verb@None@): \verb@None@):
\begin{verbatim} \begin{verbatim}
expression_stmt: expression_list expression_stmt: condition_list
\end{verbatim} \end{verbatim}
An expression statement evaluates the expression list (which may be a An expression statement evaluates the condition list (which may be a
single expression). If the value is not \verb@None@, it is converted single condition).
\indexii{expression}{list}
In interactive mode, if the value is not \verb@None@, it is converted
to a string using the rules for string conversions (expressions in to a string using the rules for string conversions (expressions in
reverse quotes), and the resulting string is written to standard reverse quotes), and the resulting string is written to standard
output (see section \ref{print}) on a line by itself. output (see section \ref{print}) on a line by itself.
\indexii{expression}{list} (The exception for \verb@None@ is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.)
\ttindex{None} \ttindex{None}
\indexii{string}{conversion} \indexii{string}{conversion}
\index{output} \index{output}
\indexii{standard}{output} \indexii{standard}{output}
\indexii{writing}{values} \indexii{writing}{values}
(The exception for \verb@None@ is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.
A tuple with only \verb@None@ items is written normally.)
\indexii{procedure}{call} \indexii{procedure}{call}
\section{Assignment statements} \section{Assignment statements}
@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
\begin{verbatim} \begin{verbatim}
def f(arg): pass # a function that does nothing (yet) def f(arg): pass # a function that does nothing (yet)
class C: pass # an class with no methods (yet) class C: pass # a class with no methods (yet)
\end{verbatim} \end{verbatim}
\section{The {\tt del} statement} \section{The {\tt del} statement}
@ -320,7 +320,7 @@ before really leaving the function.
\stindex{raise} \stindex{raise}
\begin{verbatim} \begin{verbatim}
raise_stmt: "raise" condition ["," condition] raise_stmt: "raise" condition ["," condition ["," condition]]
\end{verbatim} \end{verbatim}
\verb@raise@ evaluates its first condition, which must yield \verb@raise@ evaluates its first condition, which must yield
@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
identified by the first object, with the second one (or \verb@None@) identified by the first object, with the second one (or \verb@None@)
as its parameter. If the first object is an instance, it raises the as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as exception identified by the class of the object, with the instance as
its parameter. its parameter (and there should be no second object, or the second
object should be \verb@None@).
If a third object is present, and it it not \verb@None@, it should be
a traceback object (see section \ref{traceback}), and it is
substituted instead of the current location as the place where the
exception occurred. This is useful to re-raise an exception
transparently in an except clause.
\obindex{traceback}
\section{The {\tt break} statement} \section{The {\tt break} statement}
\stindex{break} \stindex{break}
@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
variables, respectively. variables, respectively.
Hints: dynamic evaluation of expressions is supported by the built-in Hints: dynamic evaluation of expressions is supported by the built-in
function \verb@eval()@. The built-in function \verb@vars()@ returns function \verb@eval()@. The built-in functions \verb@globals()@ and
the current local dictionary, which may be useful to pass around for \verb@locals()@ return the current global and local dictionary,
use by \verb@exec@. respectively, which may be useful to pass around for use by \verb@exec@.