[Tutor] associating two objects without ORM and processing a text file
steve at pearwood.info
Sat Feb 16 11:21:36 CET 2013
On 16/02/13 19:32, eryksun wrote:
> 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.
Ah yes, atexit doesn't *replace* the hook, it allows multiple hooks.
More information about the Tutor