there is no exitfunc in sys module

Jp Calderone exarkun at intarweb.us
Sat Jan 24 18:03:48 CET 2004


On Sat, Jan 24, 2004 at 12:07:53AM -0800, Hameed Khan wrote:
> hi,
>  i was reading the manual for sys module. i found a
> description for a function known as exitfunc. and it
> says the function installed by
> sys.exitfunc(cleanUpFunc) call will be called when the
> interpreter exits. but when i try to call this
> function on Python interactive prompt it says there is
> no attribute named exitfunc in sys module.

  Use of sys.exitfunc is deprecated.  Use the atexit module instead.

  The sys module does not have the exitfunc attribute unless you give it
one.  The proper (old, deprecated) way to do this was:

    sys.exitfunc = cleanUpFunc

  The new, non-deprecated, proper way to this is:

    atexit.register(cleanUpFuncC)

  Jp




More information about the Python-list mailing list