Deutsch English Français Italiano |
<mailman.140.1718420202.2909.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!npeer.as286.net!npeer-ng0.as286.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Cameron Simpson <cs@cskk.id.au> Newsgroups: comp.lang.python Subject: Re: Suggested python feature: allowing except in context maneger Date: Sat, 15 Jun 2024 12:56:35 +1000 Lines: 17 Message-ID: <mailman.140.1718420202.2909.python-list@python.org> References: <CAAtpb8n6C8RD527kNS3dp+DCjAWC5cPSWqSAiNXKy6oUhfvz4g@mail.gmail.com> <Zm0C4w3N7LeHX-_Q@cskk.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed X-Trace: news.uni-berlin.de y96Ff7+hKBmrKxnGE28+Cw+I9rgh4kkL/vbeF1BqZjNg== Cancel-Lock: sha1:+qqOH7yNovmL4zBv3Ho+KTXBy+k= sha256:c0n+E3PMgmW5PENnyscU1kk8xJV0/a4LAIWYnUieCMY= Return-Path: <cameron@cskk.id.au> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'usage': 0.05; 'subject:python': 0.06; 'suggestion': 0.07; 'cc:addr:python-list': 0.09; 'skip:` 10': 0.09; 'syntax': 0.15; '-1:': 0.16; 'applies': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16; 'idiom': 0.16; 'indentation': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:13.237': 0.16; 'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16; 'received:cskk.id.au': 0.16; 'received:id.au': 0.16; 'received:mail.cskk.id.au': 0.16; 'wrote:': 0.16; 'cc:addr:python.org': 0.20; "i've": 0.22; 'exception': 0.22; 'cc:2**1': 0.23; 'lines': 0.23; 'behavior': 0.26; 'brings': 0.26; 'header:User-Agent:1': 0.30; 'context': 0.32; "i'm": 0.33; 'header :In-Reply-To:1': 0.34; 'received:au': 0.35; 'change': 0.36; 'really': 0.37; 'could': 0.38; 'changes': 0.39; 'provide': 0.60; 'me.': 0.62; 'point.': 0.62; 'received:13': 0.64; 'your': 0.64; 'benefit': 0.65; 'received:userid': 0.66; 'manager': 0.68; 'managers': 0.70; 'near': 0.76; 'features.': 0.76; 'short,': 0.76; 'db,': 0.84; 'tiny': 0.84 Mail-Followup-To: Yair Eshel <guruyaya@gmail.com>, dieter.maurer@online.de, python-list@python.org Content-Disposition: inline In-Reply-To: <CAAtpb8n6C8RD527kNS3dp+DCjAWC5cPSWqSAiNXKy6oUhfvz4g@mail.gmail.com> User-Agent: Mutt/2.2.13 (2024-03-09) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 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: <https://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> X-Mailman-Original-Message-ID: <Zm0C4w3N7LeHX-_Q@cskk.homeip.net> X-Mailman-Original-References: <CAAtpb8n6C8RD527kNS3dp+DCjAWC5cPSWqSAiNXKy6oUhfvz4g@mail.gmail.com> Bytes: 4104 On 14Jun2024 09:07, Yair Eshel <guruyaya@gmail.com> wrote: >Cameron, I'm not really sure I got your point. I've used the "file not >found" exception as an example for a behavior typical on context managers. >This could be a failure to connect to DB, or threads. It also applies to >any kind of possible exception, whether cased by the context manager itself >or the lines inside it. Long story short, this syntax change is as useful >as context managers are The example exception is not what bothers me. The syntax change is nowhere near as useful as `with` and context managers. They provide an excellent idiom for resource usage and release. Your suggestion complicates the `with` statement and brings only a tiny indentation reduction over the `with`-inside-`try` idiom. It brings no semantic changes or new features. That is why I'm -1: the benefit is triviailly small to my eye.