Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37997
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@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; '(at': 0.03; '*args,': 0.07; 'function,': 0.07; '**kwargs)': 0.09; '**kwargs):': 0.09; 'def': 0.10; 'a(object):': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inheritance': 0.16; 'scope.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'jan': 0.18; 'feb': 0.19; 'trying': 0.21; '31,': 0.22; 'decorators': 0.22; 'defined': 0.22; 'skip:_ 20': 0.22; 'work,': 0.22; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'trouble': 0.28; "d'aprano": 0.29; 'declared': 0.29; 'steven': 0.29; 'class': 0.29; "i'm": 0.29; 'that.': 0.30; 'fri,': 0.30; 'function': 0.30; 'surely': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'adds': 0.35; 'jason': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'subject:with': 0.36; 'level': 0.37; 'why': 0.37; 'passed': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'think': 0.40; 'skip:u 10': 0.60; 'grab': 0.64; 'acts': 0.71; '2013': 0.84; 'locally': 0.84; 'do:': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Gb4rP3lBEMlzbSMbz+zO53nzHOqOpYoi77HWyVlOhOI=; b=qAZJ0lqMnf6MA7z6xNGhTP9r7UtaFmOpCcIpu9byC2pTl56XadwwDYHRkoV6nzj4PN H49lPxf8lxggleZZHXscB9hQVza4zBgntyUGIN9zzcuHIDqYqkE8POoVu40qowe1yjd7 KXK87pDrS7p2t0jtmT3dPKC5GPHmu36ANkAkreMTsQmkjNEDBTAiBK1BO5NH79nYyhTz JalSzVAMwbSCDs2bXY/GTn+euA6/hjT+DGdD6fuCS2Wh6mJzWfnPYB5kbUj0Gk/WfY0h SsLduxnRoOY+g4Ku9mM/Nh9vxPJpoufWVdaq3evwIJQQpJ5aKtbFEqioJzY20XVlCQpQ ku0A== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.178.225 with SMTP id db1mr7472838vdc.10.1359646122063; Thu, 31 Jan 2013 07:28:42 -0800 (PST) |
| In-Reply-To | <CAEk9e3rbH8Jt9pL4zS=g5uEJZiRiPKDP=cMzaC7D-c2dnMBsMw@mail.gmail.com> |
| References | <mailman.1239.1359592452.2939.python-list@python.org> <510a053a$0$11104$c3e8da3@news.astraweb.com> <CAEk9e3rbH8Jt9pL4zS=g5uEJZiRiPKDP=cMzaC7D-c2dnMBsMw@mail.gmail.com> |
| Date | Fri, 1 Feb 2013 02:28:41 +1100 |
| Subject | Re: confusion with decorators |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.1250.1359646129.2939.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1359646129 news.xs4all.nl 6895 [2001:888:2000:d::a6]:59828 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:37997 |
Show key headers only | View raw
On Fri, Feb 1, 2013 at 12:25 AM, Jason Swails <jason.swails@gmail.com> wrote: > On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano > <steve+comp.lang.python@pearwood.info> wrote: >> >> On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote: >> >> > Hello, >> > >> > I was having some trouble understanding decorators and inheritance and >> > all that. This is what I was trying to do: >> > >> > # untested >> > class A(object): >> > def _protector_decorator(fcn): >> > def newfcn(self, *args, **kwargs): >> > return fcn(self, *args, **kwargs) >> > return newfcn >> >> Well, that surely isn't going to work, because it always decorates the >> same function, the global "fcn". > > > I don't think this is right. fcn is a passed function (at least if it acts > as a decorator) that is declared locally in the _protector_decorator scope. > Since newfcn is bound in the same scope and fcn is not defined inside > newfcn, I'm pretty sure that newfcn will just grab the fcn passed into the > decorator. Yet it adds a level of indirection that achieves nothing. Why not simply: def _protector_decorator(fcn): return fcn ? I'm not understanding the purpose here. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
confusion with decorators Jason Swails <jason.swails@gmail.com> - 2013-01-30 19:34 -0500
Re: confusion with decorators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-31 05:46 +0000
Re: confusion with decorators Jason Swails <jason.swails@gmail.com> - 2013-01-31 08:25 -0500
Re: confusion with decorators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-01 10:16 +1100
Re: confusion with decorators Jason Swails <jason.swails@gmail.com> - 2013-01-31 22:13 -0500
Re: confusion with decorators Chris Angelico <rosuav@gmail.com> - 2013-02-01 02:28 +1100
Re: confusion with decorators Jason Swails <jason.swails@gmail.com> - 2013-01-31 11:00 -0500
Re: confusion with decorators Jason Swails <jason.swails@gmail.com> - 2013-01-31 12:53 -0500
Re: confusion with decorators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-01 08:31 +1100
Re: confusion with decorators 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-01 03:26 -0800
Re: confusion with decorators 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-01 03:26 -0800
csiph-web