Is there a way to hook into module destruction?

N

Neal Becker

Code at global scope in a module is run at module construction (init). Is
it possible to hook into module destruction (unloading)?
 
I

i3dmaster

Try the __del__ method.

Seehttp://docs.python.org/ref/customization.htmlfor the docs.

I doubt python calls __del__ when unloading module... and plus, I
don't really think python does module unloading though. del module
after import it got it removed from the global namespace but it does
not clean reference I bet, so completely unloading a module should
take more energy of that...

Jim
 
G

Gerald Kaszuba

I doubt python calls __del__ when unloading module... and plus, I
don't really think python does module unloading though. del module

Ah! Apologies... I mis-read the question.

Unloading or at least destroying the reference to a loaded module, you
could go for "del module_name"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top