On 16/02/13 19:32, eryksun wrote:
On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Aprano<st...@pearwood.info>  wrote:
while atexit can be set anywhere and isn't obvious. It's also somewhat
risky, since you never know when some library you import will silently
replace it with their own hook.

Use try/finally if the task is clearer that way. atexit is better
suited to libraries. logging uses atexit (flushing/closing handlers)
as does multiprocessing (terminating/joining active child processes).

As to the risk, atexit was added in 2.0 and directly using
sys.exitfunc was deprecated in 2.4.


Ah yes, atexit doesn't *replace* the hook, it allows multiple hooks.
Correction noted.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to