mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
documented globals() and locals()
This commit is contained in:
parent
abfa2cae9f
commit
fb502e964f
2 changed files with 42 additions and 8 deletions
|
@ -47,8 +47,11 @@ exactly one argument.)
|
|||
give the file from which the code was read; pass e.g. \code{'<string>'}
|
||||
if it wasn't read from a file. The \var{kind} argument specifies
|
||||
what kind of code must be compiled; it can be \code{'exec'} if
|
||||
\var{string} consists of a sequence of statements, or \code{'eval'}
|
||||
if it consists of a single expression.
|
||||
\var{string} consists of a sequence of statements, \code{'eval'}
|
||||
if it consists of a single expression, or \code{'single'} if
|
||||
it consists of a single interactive statement (in the latter case,
|
||||
expression statements that evaluate to something else than
|
||||
\code{None} will printed).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delattr}{object\, name}
|
||||
|
@ -112,8 +115,9 @@ exactly one argument.)
|
|||
|
||||
Hints: dynamic execution of statements is supported by the
|
||||
\code{exec} statement. Execution of statements from a file is
|
||||
supported by the \code{execfile()} function. The \code{vars()}
|
||||
function returns the current local dictionary, which may be useful
|
||||
supported by the \code{execfile()} function. The \code{globals()}
|
||||
and \code{locals()} functions returns the current global and local
|
||||
dictionary, respectively, which may be useful
|
||||
to pass around for use by \code{eval()} or \code{execfile()}.
|
||||
|
||||
\end{funcdesc}
|
||||
|
@ -158,6 +162,13 @@ removed.
|
|||
\code{\var{x}.\var{foobar}}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{globals}{}
|
||||
Return a dictionary representing the current global symbol table.
|
||||
This is always the dictionary of the current module (inside a
|
||||
function or method, this is the module where it is defined, not the
|
||||
module from which it is called).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{hasattr}{object\, name}
|
||||
The arguments are an object and a string. The result is 1 if the
|
||||
string is the name of one of the object's attributes, 0 if not.
|
||||
|
@ -206,6 +217,12 @@ removed.
|
|||
may be a sequence (string, tuple or list) or a mapping (dictionary).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{locals}{}
|
||||
Return a dictionary representing the current local symbol table.
|
||||
Inside a function, modifying this dictionary does not always have the
|
||||
desired effect.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{long}{x}
|
||||
Convert a number to a long integer. The argument may be a plain or
|
||||
long integer or a floating point number.
|
||||
|
|
|
@ -47,8 +47,11 @@ exactly one argument.)
|
|||
give the file from which the code was read; pass e.g. \code{'<string>'}
|
||||
if it wasn't read from a file. The \var{kind} argument specifies
|
||||
what kind of code must be compiled; it can be \code{'exec'} if
|
||||
\var{string} consists of a sequence of statements, or \code{'eval'}
|
||||
if it consists of a single expression.
|
||||
\var{string} consists of a sequence of statements, \code{'eval'}
|
||||
if it consists of a single expression, or \code{'single'} if
|
||||
it consists of a single interactive statement (in the latter case,
|
||||
expression statements that evaluate to something else than
|
||||
\code{None} will printed).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{delattr}{object\, name}
|
||||
|
@ -112,8 +115,9 @@ exactly one argument.)
|
|||
|
||||
Hints: dynamic execution of statements is supported by the
|
||||
\code{exec} statement. Execution of statements from a file is
|
||||
supported by the \code{execfile()} function. The \code{vars()}
|
||||
function returns the current local dictionary, which may be useful
|
||||
supported by the \code{execfile()} function. The \code{globals()}
|
||||
and \code{locals()} functions returns the current global and local
|
||||
dictionary, respectively, which may be useful
|
||||
to pass around for use by \code{eval()} or \code{execfile()}.
|
||||
|
||||
\end{funcdesc}
|
||||
|
@ -158,6 +162,13 @@ removed.
|
|||
\code{\var{x}.\var{foobar}}.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{globals}{}
|
||||
Return a dictionary representing the current global symbol table.
|
||||
This is always the dictionary of the current module (inside a
|
||||
function or method, this is the module where it is defined, not the
|
||||
module from which it is called).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{hasattr}{object\, name}
|
||||
The arguments are an object and a string. The result is 1 if the
|
||||
string is the name of one of the object's attributes, 0 if not.
|
||||
|
@ -206,6 +217,12 @@ removed.
|
|||
may be a sequence (string, tuple or list) or a mapping (dictionary).
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{locals}{}
|
||||
Return a dictionary representing the current local symbol table.
|
||||
Inside a function, modifying this dictionary does not always have the
|
||||
desired effect.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{long}{x}
|
||||
Convert a number to a long integer. The argument may be a plain or
|
||||
long integer or a floating point number.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue