[Bf-python] Importing python code from textwindow as a module

Willian Padovani Germano wgermano at ig.com.br
Thu Jul 3 07:09:31 CEST 2003


On Wed, 2003-07-02 at 23:41, John Harris wrote:
> I tried that out and it works great, just one last question. How can I 
> make it unloade the modules even when the script crashes. Thanks again 
> for the help, things will be a lot less annoying now.   asdf_46

Fine : ).

Well, there's the ugly way: put it all inside a try: ... except:
clause.  Or better, you can leave only that part of the script in
another Text, and run it to clean up when things go wrong.

I don't know any better way to handle it.

But *for normal execution*, you may like the atexit function, you can
use it to register your clean-up actions:

http://aspn.activestate.com/ASPN/Reference/Products/ActivePython/python/lib/module-atexit.html

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list