Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111025
| 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 | Sun, 3 Jul 2016 18:01:21 -0600 |
| Lines | 33 |
| Message-ID | <mailman.52.1467590530.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> <mailman.15.1467436194.2295.python-list@python.org> <facf7142-25f5-4a8b-ab37-771884ab8d64@googlegroups.com> <CALwzid=GfLU8nbc5m4M9FxEO1ObWDTcvLJ3-wJXS0=w88-v8sw@mail.gmail.com> <mailman.33.1467521333.2295.python-list@python.org> <46690e10-1534-4f99-a40f-a148b4a21a27@googlegroups.com> <CALwzidmn-0TyxfKxcZoNoV5CgiFuOqRS_X=W34gSn5a-NVOy_w@mail.gmail.com> <mailman.38.1467546815.2295.python-list@python.org> <d2f71d72-d2da-4f68-9d6a-ca059327afdd@googlegroups.com> <CALwzid=ZsBnqjcMHVU6YQ17_993z01K3wKZ2QwZb9LKF_KJt_A@mail.gmail.com> <mailman.47.1467585556.2295.python-list@python.org> <62b43f29-e6ea-4d19-9e9f-1becb3988bd3@googlegroups.com> <CALwzidn_Dxt8wuJ4dFdASkZ8Thmey4hMKXVLkXJGTiyt034A1g@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de SlGvDWq82SJYhr8RJYseTg0u2oM80vumda1NEL+SD3Fg== |
| 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.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '*args,': 0.07; '*not*': 0.07; 'caller': 0.07; '*args': 0.09; 'caller.': 0.09; 'func': 0.09; 'def': 0.13; 'applies': 0.15; '"""returns': 0.16; '2016': 0.16; 'called,': 0.16; 'docstring': 0.16; 'earlier:': 0.16; 'namespace.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:@ 20': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'posted': 0.21; 'decorator': 0.22; 'lawrence': 0.22; 'sorry,': 0.22; 'code.': 0.23; 'replacing': 0.23; 'header:In- Reply-To:1': 0.24; "doesn't": 0.26; 'example': 0.26; 'not.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'see,': 0.27; 'function': 0.28; '**kwargs)': 0.29; '**kwargs):': 0.29; "i'm": 0.30; 'returned': 0.32; 'received:google.com': 0.35; 'but': 0.36; 'assigned': 0.36; 'monday,': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'agree': 0.37; 'seem': 0.37; 'whatever': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'your': 0.60; 'claim': 0.61; 'skip:u 10': 0.61; 'here:': 0.63; 'here': 0.66; 'talking': 0.67; 'skip:\xe2 10': 0.70; 'jul': 0.72; 'decorator,': 0.84; '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 :content-transfer-encoding; bh=gdoBoWHIO9uR48qUJEm/c9HbI8T8z+2nNl+SwSJUpas=; b=uThiK1pGIMcakHGx265U4aCm6K4V8OF1fq1n4LeO3pPCO12uuSdm2iIX/HXk0vJAgk dkqyVkF9Akh3byNH3sLpAfbn1rtiwgg5AJ1KFyksZf94nDuuHIC4+nCoj+BJlY0AOCNr IUFlxhuFdG1tUXSQh3LxPrXL57en3miywLyQ5s8sHMG0nTApp6tS+diZQ0e6jpgb14Un 8qjZAs/AZFUFQ2Mdi3bLv3LCYXQdrt8vGfVS5QHCj/00Y7LXK2k+H9cIBjqo2Jgugj9o QCsIm1e9fvHx5TjMJmpWG2TP0RewcI1I/M58mZqJqblp0AYTpvDZkfKGEOOLocLUntoE 6YNA== |
| 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:content-transfer-encoding; bh=gdoBoWHIO9uR48qUJEm/c9HbI8T8z+2nNl+SwSJUpas=; b=bQhWZkxcipIKNMbtQfQulnwNpSDnq91koO31Y//glfPMDYaFhtHs/SAl0LvjAZysvr 9KNMNvMz5vJYrxtm4QuumG2p3xvD6c81teru+9jMcvsL9B/TAFHCqDJppdYVNeIqZxw+ lzAVwO89Dx3xSFlK/5e3VITGdhezlm5Wbn3tRoa0A6SS900rIy+gRIULUMqYD1s1UXkS 3+f6kFtp+/02j6Dwrmtzs8Z8C3prXmtReXB4Osttlbf6WjBI08dAr5lQFtAoj/Mxj5K+ KXu6gk5IpiZ52l56wA/L+s3AshZ6mCbZM9M7Sp4PPPGzjs+cK1PN2r3sdArrZxznmUAi EoYg== |
| X-Gm-Message-State | ALyK8tImpM6SnUCrlxtOzy4vmRncUUNDXqdQ7JvGc6XjABYHch49NH2Uj83Wl7T53h+0lROQSq5OYsnYiHM8KQ== |
| X-Received | by 10.202.181.137 with SMTP id e131mr5545011oif.144.1467590520822; Sun, 03 Jul 2016 17:02:00 -0700 (PDT) |
| In-Reply-To | <62b43f29-e6ea-4d19-9e9f-1becb3988bd3@googlegroups.com> |
| 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 | <CALwzidn_Dxt8wuJ4dFdASkZ8Thmey4hMKXVLkXJGTiyt034A1g@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> <mailman.15.1467436194.2295.python-list@python.org> <facf7142-25f5-4a8b-ab37-771884ab8d64@googlegroups.com> <CALwzid=GfLU8nbc5m4M9FxEO1ObWDTcvLJ3-wJXS0=w88-v8sw@mail.gmail.com> <mailman.33.1467521333.2295.python-list@python.org> <46690e10-1534-4f99-a40f-a148b4a21a27@googlegroups.com> <CALwzidmn-0TyxfKxcZoNoV5CgiFuOqRS_X=W34gSn5a-NVOy_w@mail.gmail.com> <mailman.38.1467546815.2295.python-list@python.org> <d2f71d72-d2da-4f68-9d6a-ca059327afdd@googlegroups.com> <CALwzid=ZsBnqjcMHVU6YQ17_993z01K3wKZ2QwZb9LKF_KJt_A@mail.gmail.com> <mailman.47.1467585556.2295.python-list@python.org> <62b43f29-e6ea-4d19-9e9f-1becb3988bd3@googlegroups.com> |
| Xref | csiph.com comp.lang.python:111025 |
Show key headers only | View raw
On Sun, Jul 3, 2016 at 5:25 PM, Lawrence D’Oliveiro <lawrencedo99@gmail.com> wrote: > On Monday, July 4, 2016 at 10:39:30 AM UTC+12, Ian wrote: >> Sorry, but you're the one who doesn't seem to get it. Because it's a >> decorator, "your" function is replacing the caller's function in the >> caller's namespace. > > No it is not. The replacement happens here: > > def generated_decorator(func) : > return \ > decorator(func, *args, **kwargs) > #end generated_decorator > > As you can see, the function being called, “decorator”, is supplied by the caller. The function being decorated, “func”, is supplied by the caller (along with the additional *args and **kwargs). And the returned function is returned *as-is*, so whatever docstring was assigned by the caller is *NOT* “clobbered”. I'm talking about the docstring of the *decorator*, not func. I agree that whatever docstring func has is entirely up to func and the decorator, not your code. Here again is the example I posted earlier: >>> @decorator_with_args ... def my_decorator(func, *args, **kwargs): ... """Returns func unmodified.""" ... return func ... >>> my_decorator.__doc__ 'generates a decorator which applies my_decorator to the given arguments' I never made any claim about the docstring of the decorated func.
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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