How do I undo an import??

Tom tom-main at REMOVEME.home.com
Fri Apr 14 21:29:11 CEST 2000


After importing NetCfg I type:

>>> del sys.modules['NetCfg']

Python responds as follows:

Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: sys

Any ideas??

Thanks,

Tom.

"Michael Hudson" <mwh21 at cam.ac.uk> wrote in message
news:m3d7nthbbj.fsf at atrus.jesus.cam.ac.uk...
> "Tom" <tom-main at REMOVEME.home.com> writes:
>
> > I'm a C++ programmer, new to Python, working with v1.5.2 on Windows.
> >
> > I run the command-line interpreter, then I type:
> >
> > >>> from NetCfg import *
> >
> > to import my extension.  Now I want to unload my NetCfg DLL without
exiting
> > the interpreter.  How do I do this?
>
> You don't, in general.
>
> del sys.modules['NetCfg']
>
> goes some of the way, but it's unlikely it goes far enough to let the
> dll be unloaded from memory.
>
> > Also, I type the above import command every time I start the
interpreter.
> > Is there some way to get have this command executed automatically?
>
> Set the environment variable "PYTHONSTARTUP" to point to a file
> containing commands you want executed.
>
> At least, that's what I do on Linux.
>
> Cheers,
> M.
>
> --
>   ... but I guess there are some things that are so gross you just have
>   to forget,  or it'll destroy something within you.  perl is the first
>   such thing I have known.                 -- Erik Naggum, comp.lang.lisp





More information about the Python-list mailing list