[Tutor] there is no exitfunc in sys module

Terry Carroll carroll at tjc.com
Sat Jan 24 12:30:05 EST 2004


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"





More information about the Tutor mailing list