Re: How to unload a module after I've imported it.
- From: "Gabriel Genellina" <gagsl-py2@xxxxxxxxxxxx>
- Date: Sat, 29 Sep 2007 18:16:08 -0300
En Sat, 29 Sep 2007 17:32:15 -0300, marvinla <marvinware2005@xxxxxxxxx> escribi�:
Have you tried a del?
['__builtins__', '__doc__', '__name__', 'socket']import socket
dir()
['__builtins__', '__doc__', '__name__']del socket
dir()
py> import socket
py> del socket
py> import sys
py> sys.modules['socket']
<module 'socket' from 'c:\apps\Python25\lib\socket.pyc'>
del only removes the reference from the current namespace, but the module is still loaded and available.
del sys.modules['socket'] would remove the module so the next import statement will have to reload it.
Back to the original question, timeoutsocket replaces some objects in the socket module with its own versions, just "unloading" timeoutsocket would not be enough, the changes had to be reverted.
timeoutsocket is an old hack for Python 2.2 and earlier. Since 2.3 you can achieve the same thing using socket.setdefaulttimeout() so unless you are forced to use such ancient versions, it can be dropped.
--
Gabriel Genellina
.
- References:
- How to unload a module after I've imported it.
- From: Johny
- Re: How to unload a module after I've imported it.
- From: marvinla
- How to unload a module after I've imported it.
- Prev by Date: Command-line does work when scheduled
- Next by Date: Re: question about for cycle
- Previous by thread: Re: How to unload a module after I've imported it.
- Next by thread: Re: How to unload a module after I've imported it.
- Index(es):
Relevant Pages
|