Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b71aef11
Commit
b71aef11
authored
Mar 19, 2004
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand on the semantics of reload(). Closes #919099.
parent
821bfc8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
Doc/lib/libfuncs.tex
Doc/lib/libfuncs.tex
+24
-2
No files found.
Doc/lib/libfuncs.tex
View file @
b71aef11
...
...
@@ -785,14 +785,36 @@ class C(object):
\end{funcdesc}
\begin{funcdesc}
{
reload
}{
module
}
Re
-parse and re-initialize an alread
y imported
\var
{
module
}
. The
Re
load a previousl
y 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).
There are a number of caveats:
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment