How do I undo an import??

Tom tom-main at REMOVEME.home.com
Fri Apr 14 04:23:19 CEST 2000


I had given my startup file the same name as my extension ... so it was
finding itself.

Tom.

"Tom" <tom-main at REMOVEME.home.com> wrote in message
news:6dvJ4.186934$Hq3.4382652 at news2.rdc1.on.home.com...
> I tried the environment variable as you suggested, pointing to a file
> containing the following:
>
> print "about to ... from NetCfg import *"
> from NetCfg import *
>
> This partially works.  Now, when I run the python shell I see the printed
> text twice, but the functions in NetCfg aren't added to the namespace.
>
> 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