sys.exit versus termination of source code

Steve Holden steve at holdenweb.com
Fri Jul 13 14:42:54 EDT 2007


Carl DHalluin wrote:
> Hi,
> 
>  
> 
> I am playing with the atexit module but I don’t find a way to see the 
> difference
> 
> between a script calling sys.exit(<returncode>) and the interpreting 
> arriving at the end
> 
> of the source code file. This has a semantic difference for my applications.
> 
> Is there a way to determine in an exithandler (that is registered using 
> atexit.register)
> 
> how I exited?
> 
I don't believe so.

>  
> 
> Second question: is there a way to determine in my exithandler what the 
> return code was.
> 
> atexit doesn’t seem to support that
> 
I don't believe so.
>  
> 
> Third question: I can solve part of my problem by reassigning sys.exit = 
> myfunction
> 
> Is that a wise idea?
> 
>  
> 
> Thanks
> 
> Carl D’Halluin
> 
> www.qlayer.com
> 
It would be much more sensible to replace the calls to sys.exit with 
calls to some function that sets the required "this was not falling off 
the end" indication and then calls sys.exit.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list