Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17148
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!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 | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'function,': 0.07; 'wrapper': 0.07; 'python': 0.08; 'decorator': 0.09; 'url:peps': 0.09; 'am,': 0.12; 'entries': 0.15; '**kwargs)': 0.16; 'constructs': 0.16; 'docstring': 0.16; 'eval': 0.16; 'wrote:': 0.18; 'int': 0.18; 'issue,': 0.18; 'prototype': 0.18; 'seems': 0.20; 'maybe': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'long.': 0.23; 'pep': 0.23; 'url:dev': 0.23; 'module': 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.29; 'python3': 0.30; "i've": 0.31; 'quite': 0.32; 'tue,': 0.32; 'pretty': 0.32; 'received:209.85.161.46': 0.32; 'received:mail- fx0-f46.google.com': 0.32; 'there': 0.33; 'to:addr:python-list': 0.34; 'tools.': 0.34; 'too': 0.34; 'help,': 0.35; 'external': 0.35; 'url:python': 0.36; 'however,': 0.36; 'starting': 0.36; 'received:209.85.161': 0.36; 'uses': 0.36; 'but': 0.37; 'received:google.com': 0.37; "there's": 0.37; 'using': 0.38; 'some': 0.38; 'received:209.85': 0.38; "i'd": 0.39; 'url:org': 0.39; 'group,': 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'inspection': 0.67; 'hassle?': 0.84; 'imagine,': 0.84; 'steam': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gqaY/1IkwsxArqaP4hUQjcesf7Okb5akf7Qr//yd2J4=; b=GjBEEVMST1d79F7AT7mBkNkBaSxsZThGVgivMjyEHkgmh5O13hXyyLb3tmHaoD//wT wfscLiHLCtVnb72PJrTQokhBC2vZeAKvcGjky2ZPvD8fr0f6Udjo1pSYHnxlursso1Sr 6XRlyrSfOX22Dkw4rfDtFXchpmK8qieNGwWtk= |
| MIME-Version | 1.0 |
| In-Reply-To | <jc7kd4$sak$1@speranza.aioe.org> |
| References | <jc7kd4$sak$1@speranza.aioe.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 13 Dec 2011 09:26:58 -0700 |
| Subject | Re: Signature-preserving decorators |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3605.1323793653.27778.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1323793653 news.xs4all.nl 6880 [2001:888:2000:d::a6]:52485 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17148 |
Show key headers only | View raw
On Tue, Dec 13, 2011 at 6:36 AM, Henrik Faber <hfaber@invalid.net> wrote: > Hi group, > > when decorating a method in Python3, by use of the > functools.update_wrapper function, it can be achieved that the docstring > and name of the original function is preseverved. > > However, the prototype is lost: When looking into the Python help, I > have lots of entries that look like: > > getfoo(*args, **kwargs) -> int > > setbar(*args, **kwargs) > > As you can imagine, this is really not very self-explanatory. I've seen > a solution which constructs a wrapper's wrapper function using > inspection and eval -- this looks really dirty to me, however. Then > there's the "decorator" external module -- but I'd like to do it with > on-board tools. > > Is this possible in Python3 with too much of a hassle? The decorator module also uses inspection and eval to do it, by the way. Currently there is no pretty way to do it that I know of, but see PEP 362: http://www.python.org/dev/peps/pep-0362/ That PEP has unfortunately been in the "Open" state for quite a long time now, but it seems to me that a lot of people are starting to get interested in this issue, so maybe it will start to pick up some steam before too long.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Signature-preserving decorators Henrik Faber <hfaber@invalid.net> - 2011-12-13 14:36 +0100 Re: Signature-preserving decorators Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 09:26 -0700
csiph-web