Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.081 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.01; 'context': 0.05; 'python': 0.10; 'received:mail-ig0-x22a.google.com': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; 'of.': 0.18; '2015': 0.20; 'aug': 0.20; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'message- id:@mail.gmail.com': 0.27; "i'm": 0.30; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'your': 0.60; 'leaving': 0.63; 'managers': 0.63; 'sounds': 0.76; 'to:name:python': 0.84; 'instrument': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=v57DYrYmBNvI7tyFYpa2kZyXL+qCcyd0jSICIcZbSRE=; b=LyWsQQcee0R3UuGI+1piKzjOjnbyTKSUlaInhVEAw8D2fvL+CEdPTH+7QkV41KCxP/ NwJlzy7ZZvRaoDvQlfMANDRyvUJuPRaNpgAy0rDR2Lkv5wHlBpcI4j9T7V4YxjRA/SlD u5cv6eshgmfFHBF7EN3nv+3YOp2WubmG307n2KidocYrsmbnniz5athsLr7f2F4MyqZO OGttAH+dggUWXQXGmgFv/lPAwSoRgT/yLmFYGLcODqZ8r8lsRRIZ6LBESSG7fKgadl/1 TEz4xRn6ybccAqSJe4fYEiK3IncwEllEMiaNulmcZ+gNQ8Sk1+8WNknPylMS/LIZxiil YnHg== X-Received: by 10.50.73.170 with SMTP id m10mr25475994igv.60.1439393595622; Wed, 12 Aug 2015 08:33:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <55CA6D7F.1060705@mail.de> References: <55CA6D7F.1060705@mail.de> From: Ian Kelly Date: Wed, 12 Aug 2015 09:32:36 -0600 Subject: Re: Hooking Mechanism when Entering and Leaving a Try Block To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 8 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439393598 news.xs4all.nl 2926 [2001:888:2000:d::a6]:50541 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3164 X-Received-Body-CRC: 2097802739 Xref: csiph.com comp.lang.python:95284 On Tue, Aug 11, 2015 at 3:47 PM, Sven R. Kunze wrote: > is there something like a hook that a Python module could register to in > order to 'trace' the entering and leaving of arbitrary try blocks? Not that I'm aware of. However, it sounds like context managers might do what you want. You would just need to instrument your try blocks by adding with blocks.