Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'decorator': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'func': 0.09; 'idle,': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'def': 0.13; 'argument': 0.15; '*a,': 0.16; "function's": 0.16; 'module:': 0.16; 'received:67.18.44': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'tested)': 0.16; 'wrote:': 0.18; '2.x': 0.18; "haven't": 0.20; 'header:In-Reply-To:1': 0.22; 'somehow': 0.23; 'code': 0.25; 'testing': 0.26; 'function': 0.27; 'import': 0.27; 'do.': 0.28; 'chris': 0.30; 'actual': 0.32; 'header:User-Agent:1': 0.33; 'rather': 0.33; 'instead': 0.33; 'to:addr:python-list': 0.34; 'see,': 0.34; 'list.': 0.35; 'but': 0.37; 'useful': 0.38; 'help': 0.39; 'to:addr:python.org': 0.40; 'received:websitewelcome.com': 0.64; 'here': 0.65; 'piece': 0.66; 'received:184': 0.67; 'subject:!!!': 0.76 Date: Thu, 08 Dec 2011 15:56:58 -0800 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: I love the decorator in Python!!! References: <29996186.628.1323328726122.JavaMail.geo-discussion-forums@prfb7> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:4316 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323391888 news.xs4all.nl 6940 [2001:888:2000:d::a6]:43175 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16886 Chris Angelico wrote: > One piece of sophistication that I would rather like to see, but don't > know how to do. Instead of *args,**kwargs, is it possible to somehow > copy in the function's actual signature? I was testing this out in > IDLE, and the fly help for the function no longer gave useful info > about its argument list. And here it is with Michele's decorator module: 2.x code (probably the same in 3.x, but haven't tested) ---------------------------------------------------------------- from decorator import decorator debugmode = True def trace(func): if debugmode: @decorator def traced(func, *a, **ka): print(">", func.__name__, a, ka) result = func(*a, **ka) print("<", func.__name__) return result return traced(func) return func @trace def test(x): "a simple test" print("Test! "+x) return 5 ---------------------------------------------------------------- ~Ethan~