Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110944
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Meta decorator with parameters, defined in explicit functions |
| Date | Fri, 1 Jul 2016 23:53:15 -0600 |
| Lines | 25 |
| Message-ID | <mailman.17.1467438837.2295.python-list@python.org> (permalink) |
| References | <85mvm5vrbw.fsf@benfinney.id.au> <mailman.61.1467090177.2358.python-list@python.org> <21916e7b-9e19-4cef-94e0-bac331540ca2@googlegroups.com> <CALwzidn8DuSo-L2UQTJ7wZfzK+eHGzgGuy_ZfHFR9v4J_NHnjQ@mail.gmail.com> <85oa6gtxk3.fsf@benfinney.id.au> <CALwzid=2x0prTzzgkk3gePS5B_iWiDjk298ZNKe_L0M7beH6Gg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de o950/7PWWQidSKFczwb/9wqCdosq/VuVtwxdnjrwE0Sg== |
| 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.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'args': 0.04; '"""': 0.05; '*args,': 0.07; 'wrapper': 0.07; 'kwargs': 0.09; 'separately': 0.09; 'def': 0.13; '"""given': 0.16; '11:32': 0.16; '2016': 0.16; 'docstring': 0.16; 'received:io': 0.16; 'received:mail- oi0-x230.google.com': 0.16; 'received:psf.io': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.16; 'thanks.': 0.18; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; '**kwargs)': 0.29; '**kwargs):': 0.29; 'accepts': 0.29; 'that,': 0.34; 'received:google.com': 0.35; 'skip:i 20': 0.36; 'should': 0.36; 'instead': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'sure': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'subject:with': 0.40; 'jul': 0.72; 'to:name:python': 0.84 |
| 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; bh=218dqfJTYYyj5RpWniYtcvQnxP/s2AaqufiXpmE9FIw=; b=ZuYCuiLirjdmiH5YCb6WoSt1Y4bIHeAVN4ntMgoHd/AQQuIsHDrINhhHLcFXKcVNFi tz0nGVDdkZcC1TAvMXxYVNj9U+evSNMG9W3iNMqxyi747O+ZiGFgBQPJcrqE7iV6tfvu 1tltjSK8wdkBdAVxINX7/fAJOFslx5Imm3+T9BiWBXCesnqDgOmHf1kZvCAI3PVUSIM/ wUeuQbiHp983kY7JTisIrFL/AHWCoiyguIZV3GEN7GtgxolBCZfmo89hZiy37K+6nX0S AWjWNUPePdB+5DjSs64TQRiS9wghpzb4ZQj4/KCr9HDvLZksN2kOA4p9vFyj6WiOkXIB tbdQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=218dqfJTYYyj5RpWniYtcvQnxP/s2AaqufiXpmE9FIw=; b=bmdFCaca8xdBKO7Snn5VEOKzclzYsfh0Crt1d2gLNTL0ZUzPsevABLYGOznqsN3e8i 77NbJeVqwNWNfdTAWlSxhvsk13OVULfWVdV2uNxttUEESAR8fre3fDhaVdZz2YWVOk6S w2tmW/rtXvu3tZmAtOhFq81IsnXlOTRlmyp15YsfjI6aJJ1h1ZUTuaqU0DN9oYQyDHnI w9ccEWD5vVtToRWLha8vr6gQAGJbOcEPnbSg20vC2+eil5IMakodcw9WCfDQrteH7Pe0 zqzfjQIolFxCj1y3eNagDzvD8/M6tYnXivUI+K3BdyaCFBtUpxOLDIuTU6LpnL3pi6NH CzfA== |
| X-Gm-Message-State | ALyK8tJszEhyX0xE6dL0wsA8BElT+goIECZCmR1kwL1Q6iB1tJ2Mcyhb5IS1VU7WD/C++wkljJ6L9a4jPuX8xA== |
| X-Received | by 10.202.231.83 with SMTP id e80mr1076958oih.159.1467438834909; Fri, 01 Jul 2016 22:53:54 -0700 (PDT) |
| In-Reply-To | <85oa6gtxk3.fsf@benfinney.id.au> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <CALwzid=2x0prTzzgkk3gePS5B_iWiDjk298ZNKe_L0M7beH6Gg@mail.gmail.com> |
| X-Mailman-Original-References | <85mvm5vrbw.fsf@benfinney.id.au> <mailman.61.1467090177.2358.python-list@python.org> <21916e7b-9e19-4cef-94e0-bac331540ca2@googlegroups.com> <CALwzidn8DuSo-L2UQTJ7wZfzK+eHGzgGuy_ZfHFR9v4J_NHnjQ@mail.gmail.com> <85oa6gtxk3.fsf@benfinney.id.au> |
| Xref | csiph.com comp.lang.python:110944 |
Show key headers only | View raw
On Fri, Jul 1, 2016 at 11:32 PM, Ben Finney <ben+python@benfinney.id.au> wrote:
> Ian Kelly <ian.g.kelly@gmail.com> writes:
>
>> You should use functools.wraps instead of clobbering the decorated
>> function's name and docstring:
>>
>> @functools.wraps(decorator)
>> def decorate(*args, **kwargs):
>> ...
>
> Thanks. Can you write the full implementation with that, so I can be
> sure of where you expect that to go?
def decorator_with_args(decorator):
"""Given function decorator(func, *args, **kwargs), returns a
wrapper that accepts args and kwargs separately from func.
"""
@functools.wraps(decorator)
def apply(*args, **kwargs):
# inner_decorator is transient, so its name and docstring
# are unimportant.
def inner_decorator(func):
return decorator(func, *args, **kwargs)
return inner_decorator
return apply
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Meta decorator with parameters, defined in explicit functions Ben Finney <ben+python@benfinney.id.au> - 2016-06-28 15:02 +1000
Re: Meta decorator with parameters, defined in explicit functions Paul Rubin <no.email@nospam.invalid> - 2016-06-27 23:08 -0700
Re: Meta decorator with parameters, defined in explicit functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-28 18:39 +1000
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-29 19:43 -0700
Re: Meta decorator with parameters, defined in explicit functions Steven D'Aprano <steve@pearwood.info> - 2016-06-30 13:49 +1000
Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Peter Otten <__peter__@web.de> - 2016-06-30 09:25 +0200
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 00:43 -0700
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-30 18:00 +1000
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Peter Otten <__peter__@web.de> - 2016-06-30 10:41 +0200
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions dieter <dieter@handshake.de> - 2016-07-01 09:04 +0200
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-01 21:25 +0100
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Ben Finney <ben+python@benfinney.id.au> - 2016-07-02 11:52 +1000
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions dieter <dieter@handshake.de> - 2016-07-02 08:57 +0200
Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Ben Finney <ben+python@benfinney.id.au> - 2016-07-02 18:00 +1000
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-29 19:50 -0700
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-01 15:08 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-01 23:09 -0600
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-01 23:40 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-02 22:48 -0600
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-02 22:37 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-03 05:52 -0600
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 14:17 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-03 16:38 -0600
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 16:25 -0700
Re: Meta decorator with parameters, defined in explicit functions Chris Angelico <rosuav@gmail.com> - 2016-07-04 09:39 +1000
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 16:59 -0700
Re: Meta decorator with parameters, defined in explicit functions Chris Angelico <rosuav@gmail.com> - 2016-07-04 10:06 +1000
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 17:23 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-03 18:01 -0600
Re: Meta decorator with parameters, defined in explicit functions Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-03 17:06 -0700
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-03 18:20 -0600
Re: Meta decorator with parameters, defined in explicit functions Ben Finney <ben+python@benfinney.id.au> - 2016-07-02 15:32 +1000
Re: Meta decorator with parameters, defined in explicit functions Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-01 23:53 -0600
csiph-web