Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94509

Re: register cleanup handler

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 <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'finally:': 0.05; 'badly': 0.07; 'cc:addr:python-list': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:89.233': 0.16; 'received:89.233.217': 0.16; 'received:89.233.217.133': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'laura': 0.18; 'try:': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'so.': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'received:se': 0.29; 'skip:d 20': 0.34; 'but': 0.36; 'subject:: ': 0.37; 'missing': 0.37; 'charset:us-ascii': 0.37; 'wrong': 0.38; 'header:Message-Id:1': 0.61; 'you.': 0.64; 'jul': 0.72; 'received:89': 0.80; 'becker': 0.84; 'try.': 0.91
To Neal Becker <ndbecker2@gmail.com>
cc python-list@python.org
From Laura Creighton <lac@openend.se>
Subject Re: register cleanup handler
In-Reply-To Message from Neal Becker <ndbecker2@gmail.com> of "Fri, 24 Jul 2015 10:57:30 -0400." <motjor$vv$1@ger.gmane.org>
References <motjor$vv$1@ger.gmane.org>
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-ID <27841.1437752863.1@fido>
Date Fri, 24 Jul 2015 17:47:43 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [89.233.217.130]); Fri, 24 Jul 2015 17:47:46 +0200 (CEST)
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.951.1437752878.3674.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1437752878 news.xs4all.nl 2922 [2001:888:2000:d::a6]:53607
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94509

Show key headers only | View raw


In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes:
>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?

I think so.  Either that or I am badly misunderstanding you.  What is
wrong with

try:
   if (condition):
      do_something_needing_cleanup
   else:
      do_something_else
   code_executed_unconditionally
finally:
   do_cleanup

Laura

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: register cleanup handler Laura Creighton <lac@openend.se> - 2015-07-24 17:47 +0200

csiph-web