[Tutor] there is no exitfunc in sys module
orbitz at ezabel.com
orbitz at ezabel.com
Sat Jan 24 12:48:24 EST 2004
The python.org module help says:
exitfunc
This value is not actually defined by the module, but can be set by
the user (or by a program) to specify a clean-up action at program exit.
When set, it should be a parameterless function. This function will be
called when the interpreter exits. Only one function may be installed in
this way; to allow multiple functions which will be called at
termination, use the atexit module. Note: The exit function is not
called when the program is killed by a signal, when a Python fatal
internal error is detected, or when os._exit() is called.
On Sat, 24 Jan 2004 09:30:05 -0800 (PST)
Terry Carroll <carroll at tjc.com> wrote:
> On Sat, 24 Jan 2004, Hameed Khan wrote:
>
> > 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.
>
> It doesn't exist by default. It's a function that you set up to be
> called at terminatio. Try this::
>
> import sys
>
> def outtahere():
> print "Okay, I quit"
>
> sys.exitfunc=outtahere
>
> print "program starting"
> # do something
> print "program done, now exiting"
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list