diff options
author | Guido van Rossum <guido@python.org> | 1995-07-07 22:58:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-07-07 22:58:28 (GMT) |
commit | fb502e964f3b04338020ef66d6cd59d52ad8317a (patch) | |
tree | d4985b4d09f054ab90ef8d7d7a6abd5c0fa58228 /Doc/libfuncs.tex | |
parent | abfa2cae9f17f1a2a7be8d1c5328ccb9cdcd5ef1 (diff) | |
download | cpython-fb502e964f3b04338020ef66d6cd59d52ad8317a.zip cpython-fb502e964f3b04338020ef66d6cd59d52ad8317a.tar.gz cpython-fb502e964f3b04338020ef66d6cd59d52ad8317a.tar.bz2 |
documented globals() and locals()
Diffstat (limited to 'Doc/libfuncs.tex')
-rw-r--r-- | Doc/libfuncs.tex | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Doc/libfuncs.tex b/Doc/libfuncs.tex index b526fcc..53d5100 100644 --- a/Doc/libfuncs.tex +++ b/Doc/libfuncs.tex @@ -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. |