unloading a module
exarkun at intarweb.us
Thu Mar 13 19:26:12 CET 2003
On Thu, Mar 13, 2003 at 10:57:50AM -0700, David Bear wrote:
> I've grown used to using python interactively and would like to be able to
> unload a module after I've imported it. Is there a way to do this?
This isn't directly supported by the interpreter. You may acheive the
result you seek by removing -all- references to the module. This includes
the obvious ones, like those created by the "import" statement in the local
scope and in the sys.modules object, as well as the not-so-obvious ones,
like those held by instances of types defined in the module, etc.
If your goal is what I suspect it is, to grab a new version of the module
on disk without starting a new interactive session, the reload() builtin
might be of interest.
A sad spectacle. If they be inhabited, what a scope for misery
and folly. If they be not inhabited, what a waste of space.
-- Thomas Carlyle, looking at the stars
up 10 days, 9:59, 3 users, load average: 0.00, 0.00, 0.00
More information about the Python-list