Seems so far the common way to fully unload any import is to exit the
Python session.
Only if this is true do I offer this hackish idea:
Therefore you might wish to run an os script instead of a python
script right off.
Here is my hack at it... Something like this:
file myapp.bat
--
btw if you like processing text outside of python (say using grep or
something)
python -c help('modules') all_imports.log
which you might note on windows get's processed to:
python -c help('modules') 1 all_imports.log
on windows from within a batch file
--
Gelonida N wrote:
I wondered whether there is any way to un-import a library, such, that
it's occupied memory and the related shared libraries are released.
My usecase is following:
success = False
try:
import lib1_version1 as lib1
import lib2_version1 as lib2
success = True
Jean-Michel Pichavant wrote:
Gelonida N wrote:
I wondered whether there is any way to un-import a library, such, that
it's occupied memory and the related shared libraries are released.
My usecase is following:
success = False
try:
import lib1_version1 as lib1
import lib2_version1
On Nov 20, 12:21 pm, Gelonida N gelon...@gmail.com wrote:
I forgot to mention, that this is at the moment more a thought
experiment, than a real need.
At the moment I will do exactly what you suggested. I will make sure,
that always the first import fails.
But I wanted to learn more what is
I wondered whether there is any way to un-import a library, such, that
it's occupied memory and the related shared libraries are released.
My usecase is following:
success = False
try:
import lib1_version1 as lib1
import lib2_version1 as lib2
success = True
except ImportError:
del sys.modules['my-module']
However if your module imported other modules, they'll still be there.
If there are references to objects your module created, they'll still be there.
A better option IMO is to use imp.find_module and then import.
--
On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote:
I wondered whether there is any way to un-import a library, such, that
it's occupied memory and the related shared libraries are released.
Not really. Python modules are objects, like everything else in Python,
and can only be deleted
Steven, Mika,
Thanks for your answers.
It's always good to know which options exist.
It makes it easier to choose the right one depending on the situation.
On 11/20/2011 04:46 PM, Steven D'Aprano wrote:
On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote:
I wondered whether there is any
On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N gelon...@gmail.com wrote:
No mixing would not be possible.
So either I need the first two libs or the second two.
I wonder, can you make the first one import the second one? That
automatically defines your dependency right there, and may make things
I forgot to mention, that this is at the moment more a thought
experiment, than a real need.
On 11/20/2011 05:53 PM, Chris Angelico wrote:
On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N gelon...@gmail.com wrote:
No mixing would not be possible.
So either I need the first two libs or the second
On Nov 21, 1:15 am, Gelonida N gelon...@gmail.com wrote:
I wondered whether there is any way to un-import a library, such, that
it's occupied memory and the related shared libraries are released.
My usecase is following:
success = False
try:
import lib1_version1 as lib1
import
12 matches
Mail list logo