Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94507
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.028 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'cleanup': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'code': 0.30; 'this?': 0.34; 'skip:d 20': 0.34; 'so,': 0.35; 'something': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'really': 0.37; 'being': 0.37; 'received:org': 0.37; 'missing': 0.37; 'sure': 0.39; 'to:addr:python.org': 0.40; 'actually,': 0.84; 'received:139': 0.91; 'try.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Neal Becker <ndbecker2@gmail.com> |
| Subject | register cleanup handler |
| Date | Fri, 24 Jul 2015 10:57:30 -0400 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | exa2-in-fw-01-epn.hns.com |
| User-Agent | KNode/4.14.9 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.950.1437749869.3674.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1437749869 news.xs4all.nl 2821 [2001:888:2000:d::a6]:43219 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:94507 |
Show key headers only | View raw
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