Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.075 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.00; 'context': 0.04; 'through,': 0.07; 'decorator': 0.09; 'dependency': 0.09; 'generators': 0.09; 'reply-to:addr:comp.lang.python': 0.09; 'to:addr:comp.lang.python': 0.09; 'wednesday,': 0.15; 'try- finally': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'correct,': 0.23; 'referring': 0.23; 'cc:2**0': 0.24; 'object,': 0.24; 'thanks.': 0.26; 'yield': 0.29; 'cc:addr:python.org': 0.29; 'generally': 0.30; 'construct': 0.30; 'second,': 0.30; 'semantics': 0.30; 'syntax,': 0.30; 'changes': 0.32; 'header:User- Agent:1': 0.33; 'there': 0.33; 'subject:/': 0.35; 'but': 0.37; 'run': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'created': 0.38; 'received:209': 0.40; 'happens': 0.40; 'within': 0.60; 'more': 0.61; 'illegal': 0.63; 'from:no real name:2**0': 0.63; 'guarantee': 0.65; 'believe': 0.65; '2012': 0.67; '11,': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:googlegroups.com': 0.74; 'irrelevant.': 0.84; 'passage': 0.84; 'received:209.85.213.184': 0.84; 'received:mail- yx0-f184.google.com': 0.84; 'subject:try': 0.84; 'light.': 0.91 Newsgroups: comp.lang.python Date: Wed, 11 Jan 2012 09:30:58 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=64.22.160.1; posting-account=Hml8lgoAAAAqvUa2ECJMHkzON20UWKgQ References: <10841855.1646.1326296715536.JavaMail.geo-discussion-forums@yqiz15> User-Agent: G2/1.0 X-Google-Web-Client: true MIME-Version: 1.0 Subject: Re: contextlib.contextmanager and try/finally From: johannh@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: comp.lang.python@googlegroups.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326303066 news.xs4all.nl 6849 [2001:888:2000:d::a6]:36838 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18840 On Wednesday, January 11, 2012 11:20:19 AM UTC-6, Ian wrote: >=20 > Second, I believe that passage is not referring to the contextmanager > decorator specifically, but more generally to the changes that were > made to allow generators to yield from within a try-finally construct > (previously this would have been illegal syntax, since there was no > way to guarantee the finally block would be performed). Thanks. You and Robert have shown me the light. That paragraph was talkin= g about the finalization that happens to a suspended generator when it is G= C'd. Meanwhile, the contextmanager decorator ensures that its generator is= run all the way through, so it would never be left in a suspended state, s= o its GC/finalization semantics are irrelevant. (Please correct, if wrong.) (Neil: I understood that it created a context manager object, but I had bee= n reading the quoted paragraph to mean that by going through a generator th= e decorator was re-introducing a dependency on GC time. But I was wrong.) Regards, Johann