None module reference
Kay Schluehr
kay.schluehr at gmx.net
Sun May 22 02:14:05 EDT 2005
Stefan Seefeld wrote:
> hello,
>
> I'v run into a bug that I find hard to understand:
>
> In a python module of mine I import system modules
> ('sys', say) and then use them from within some functions.
>
> However, during program termination I'm calling
> one such function and the module reference ('sys')
> is 'None' !
Do You register Your function using atexit() ?
This works perfectly fine and as expected for me. I would wonder if the
interpreter was shut down and tries to execute a cleanup thereafter.
Checkout following example code. You may also have a look at the
/lib/atexit.py module see how it works.
import atexit
import sys
def foo():
print sys
atexit.register(foo)
Ciao,
Kay
More information about the Python-list
mailing list