summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libfuncs.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libfuncs.tex')
-rw-r--r--Doc/lib/libfuncs.tex76
1 files changed, 0 insertions, 76 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index 5e6e2a0..4f49e33 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -890,82 +890,6 @@ class Parrot(object):
\end{verbatim}
\end{funcdesc}
-\begin{funcdesc}{reload}{module}
- Reload a previously imported \var{module}. The
- argument must be a module object, so it must have been successfully
- imported before. This is useful if you have edited the module
- source file using an external editor and want to try out the new
- version without leaving the Python interpreter. The return value is
- the module object (the same as the \var{module} argument).
-
- When \code{reload(module)} is executed:
-
-\begin{itemize}
-
- \item Python modules' code is recompiled and the module-level code
- reexecuted, defining a new set of objects which are bound to names in
- the module's dictionary. The \code{init} function of extension
- modules is not called a second time.
-
- \item As with all other objects in Python the old objects are only
- reclaimed after their reference counts drop to zero.
-
- \item The names in the module namespace are updated to point to
- any new or changed objects.
-
- \item Other references to the old objects (such as names external
- to the module) are not rebound to refer to the new objects and
- must be updated in each namespace where they occur if that is
- desired.
-
-\end{itemize}
-
- There are a number of other caveats:
-
- If a module is syntactically correct but its initialization fails,
- the first \keyword{import} statement for it does not bind its name
- locally, but does store a (partially initialized) module object in
- \code{sys.modules}. To reload the module you must first
- \keyword{import} it again (this will bind the name to the partially
- initialized module object) before you can \function{reload()} it.
-
- When a module is reloaded, its dictionary (containing the module's
- global variables) is retained. Redefinitions of names will override
- the old definitions, so this is generally not a problem. If the new
- version of a module does not define a name that was defined by the
- old version, the old definition remains. This feature can be used
- to the module's advantage if it maintains a global table or cache of
- objects --- with a \keyword{try} statement it can test for the
- table's presence and skip its initialization if desired:
-
-\begin{verbatim}
-try:
- cache
-except NameError:
- cache = {}
-\end{verbatim}
-
-
- It is legal though generally not very useful to reload built-in or
- dynamically loaded modules, except for \refmodule{sys},
- \refmodule[main]{__main__} and \refmodule[builtin]{__builtin__}. In
- many cases, however, extension modules are not designed to be
- initialized more than once, and may fail in arbitrary ways when
- reloaded.
-
- If a module imports objects from another module using \keyword{from}
- \ldots{} \keyword{import} \ldots{}, calling \function{reload()} for
- the other module does not redefine the objects imported from it ---
- one way around this is to re-execute the \keyword{from} statement,
- another is to use \keyword{import} and qualified names
- (\var{module}.\var{name}) instead.
-
- If a module instantiates instances of a class, reloading the module
- that defines the class does not affect the method definitions of the
- instances --- they continue to use the old class definition. The
- same is true for derived classes.
-\end{funcdesc}
-
\begin{funcdesc}{repr}{object}
Return a string containing a printable representation of an object.
This is the same value yielded by conversions (reverse quotes).