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


Groups > comp.lang.python > #95289

Re: Hooking Mechanism when Entering and Leaving a Try Block

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.027
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'ast': 0.09; 'statements': 0.09; 'thu,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; '13,': 0.29; 'code': 0.30; 'possibly': 0.32; 'received:google.com': 0.35; 'replace': 0.35; 'something': 0.35; 'should': 0.36; 'subject:: ': 0.37; 'some': 0.40; 'skip:u 10': 0.61; 'no.': 0.62; 'million': 0.74; 'sounds': 0.76; 'chrisa': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=+MnyoxulLCsAr0jM4AsyQd29iqVGsGH1ZScem2L/a8g=; b=PgiRMciqbkZDTFaWksKNgIGhDODAymeTLt4v7yUs/+nZt38nEGbLl8OgcXRBe27tk7 MQAhyvPxRnPUyJlLVc43qLGGEu9z0SQ6B/RzMRJsV2ZDqDUNjT5Bq1CZ9gS88gyqwEkA p1i5KdcXwS77iqZs/WV9wXMCVy4ekBkEilIlRpzwwqbUrEY0dEoQDK9aW+3siXqSLrhv EnH83Op8ZDVsqX0YUSFo0sEbeCfyoEUH7U+I5y2SDQEPPFSayVbw8Kx5uW8O7d7VxJ2n PTEio4Ylk/o/76HUsnUkBJP3/eUqGSYldOWXacmNGE1/LrwXV13VbClywhSkFf7cHWtL Ga7Q==
MIME-Version 1.0
X-Received by 10.107.31.134 with SMTP id f128mr31898341iof.19.1439395886852; Wed, 12 Aug 2015 09:11:26 -0700 (PDT)
In-Reply-To <55CB6EAC.5040004@mail.de>
References <55CA6D7F.1060705@mail.de> <CALwzidkBoDo1TZj2CWfimYtagtArN9r9dvw1Ke9HqcthdipV4Q@mail.gmail.com> <55CB6EAC.5040004@mail.de>
Date Thu, 13 Aug 2015 02:11:26 +1000
Subject Re: Hooking Mechanism when Entering and Leaving a Try Block
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.116.1439395889.3627.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1439395889 news.xs4all.nl 2822 [2001:888:2000:d::a6]:42484
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3376
X-Received-Body-CRC 1008268213
Xref csiph.com comp.lang.python:95289

Show key headers only | View raw


On Thu, Aug 13, 2015 at 2:05 AM, Sven R. Kunze <srkunze@mail.de> wrote:
> Unfortunately, no. :(
>
> It should work out of the box with no "let me replace all my try-except
> statements in my 10 million line code base".

(Please don't top-post.)

Sounds to me like you want some sort of AST transform, possibly in an
import hook. Check out something like MacroPy for an idea of how
powerful this sort of thing can be.

ChrisA

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


Thread

Re: Hooking Mechanism when Entering and Leaving a Try Block Chris Angelico <rosuav@gmail.com> - 2015-08-13 02:11 +1000

csiph-web