[Tutor] associating two objects without ORM and processing a text file

eryksun eryksun at gmail.com
Sat Feb 16 09:32:29 CET 2013


On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Aprano <steve at 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.


More information about the Tutor mailing list