Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94507
| From | Neal Becker <ndbecker2@gmail.com> |
|---|---|
| Subject | register cleanup handler |
| Date | 2015-07-24 10:57 -0400 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.950.1437749869.3674.python-list@python.org> (permalink) |
I have code like: if (condition): do_something_needing_cleanup code_executed_unconditionally <cleanup has to happen here if required, even if above did return, continue or exception> Now, how can I make sure cleanup happens? Actually, what I really would like, is: if (condition): do_something_needing_cleanup register_scoped_cleanup (cleanup_fnc) code_executed_unconditionally So, any thoughts/hopes of python being able to do something like this? I know we have try/finally, but I don't think that helps here, because code_executed_unconditionally couldn't be inside the try. Or am I missing something obvious?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
register cleanup handler Neal Becker <ndbecker2@gmail.com> - 2015-07-24 10:57 -0400
Re: register cleanup handler Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-07-24 18:41 +0200
Re: register cleanup handler Neal Becker <ndbecker2@gmail.com> - 2015-07-24 13:35 -0400
csiph-web