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


Groups > comp.lang.python > #103966

Re: yield in try/finally case

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: yield in try/finally case
Date Thu, 03 Mar 2016 10:00:46 -0500
Lines 11
Message-ID <mailman.149.1457017249.20602.python-list@python.org> (permalink)
References <84965b86-819b-4924-bca9-e82eed040606@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de 6dG0ohupLjhMsGCgwPzy7QN2HCM3PHBkarsA6hqa2sng==
Return-Path <random832@fastmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'clause': 0.07; 'received:internal': 0.09; "hasn't": 0.15; 'thu,': 0.15; '__del__': 0.16; 'construct.': 0.16; 'executed;': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'received:psf.io': 0.16; 'subject:case': 0.16; 'subject:yield': 0.16; 'then?': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.24; 'yield': 0.27; 'pep': 0.29; 'url:peps': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'says': 0.32; 'statement': 0.32; 'url:python': 0.33; 'url:dev': 0.35; 'too': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'why': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'reached': 0.60; 'ever': 0.60; 'header:Message-Id:1': 0.61; 'mar': 0.65; 'difficulty': 0.66; 'finally': 0.70; 'saw': 0.77; 'aiui': 0.84; 'subject:try': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=+6nYskmRRFkdIVNT57hljTOag6k=; b=lGyfj5 0A8Vh/OzfOCQHZJmebwtfwuPBFH1UTjM5PE73xrB3bnmfbaKFOWBdCqE42wSUHTO KFUIolMZNixbC+qtRJx6ixKi9SzendBIbkNro26qDzIkorEGA7xXT5BB3t+33bpe a44G8w67SNSfEukWskxyFB1naChLJG0D6Nspg=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=+6nYskmRRFkdIVN T57hljTOag6k=; b=IqaMS2EoWFvHLqRP/vtKNkoWSVqGkpSR0sRgvJAy2/+tBvI DAMM29hpyP8b6XonxefRS2reeKirGUcehKCG4InH5TeP7KybTstAxpxTYqqrQ4ti baq2/+1vlkvUaS0JrOtXFlVyrt7nTcQ3PPcTtcCJruzfHCBfj5okXoITGzX8=
X-Sasl-Enc mEaUKwydqw6ypb7fy9jgfrAOVKBh5B64kNjWRWZ2lh/7 1457017246
X-Mailer MessagingEngine.com Webmail Interface - ajax-b8d6474a
In-Reply-To <84965b86-819b-4924-bca9-e82eed040606@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
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>
Xref csiph.com comp.lang.python:103966

Show key headers only | View raw


On Thu, Mar 3, 2016, at 06:52, 刘琦帆 wrote:
> I have just saw PEP 255, and it says that 
> 
> "A yield statement is not allowed in the try clause of a try/finally
> construct.  The difficulty is that there's no guarantee the generator
> will ever be resumed, hence no guarantee that the finally block will ever
> get executed; that's too much a violation of finally's purpose to bear."
> from https://www.python.org/dev/peps/pep-0255/

I'm not sure I understand this reasoning. Why not simply execute it in
__del__ if it hasn't been reached until then? AIUI that is what C# does.

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


Thread

yield in try/finally case 刘琦帆 <lqf.txx@gmail.com> - 2016-03-03 03:52 -0800
  Re: yield in try/finally case Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-03 12:13 +0000
    Re: yield in try/finally case 刘琦帆 <lqf.txx@gmail.com> - 2016-03-03 04:52 -0800
      Re: yield in try/finally case Peter Otten <__peter__@web.de> - 2016-03-03 14:47 +0100
      Re: yield in try/finally case Random832 <random832@fastmail.com> - 2016-03-03 10:12 -0500
      Re: yield in try/finally case Peter Otten <__peter__@web.de> - 2016-03-03 17:20 +0100
      Re: yield in try/finally case Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-03 16:24 +0000
  Re: yield in try/finally case Random832 <random832@fastmail.com> - 2016-03-03 10:00 -0500
    Re: yield in try/finally case Steven D'Aprano <steve@pearwood.info> - 2016-03-04 02:57 +1100

csiph-web