Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49776

Decorator help

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jcasale@activenetwerx.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'args': 0.07; 'error:': 0.07; 'subject:help': 0.08; 'try:': 0.09; 'val': 0.09; 'wrapped': 0.09; 'def': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; 'received:172.18.0': 0.16; 'to:name:python-list@python.org': 0.22; 'values': 0.27; 'skip:@ 10': 0.30; 'thanks!': 0.32; 'except': 0.35; 'something': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:unknown': 0.61; 'name': 0.63; 'within': 0.65; 'decorate': 0.84
X-Cloudmark-SP-Filtered true
X-Cloudmark-SP-Result v=1.1 cv=+lz5uX4xiInwtrymCIFxsZpC13k2qgqBCqxhxbRs02Y= c=1 sm=1 a=P90J6pEA2ccA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=QO48HOcqDi9SrXpL-JgA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
From "Joseph L. Casale" <jcasale@activenetwerx.com>
To "python-list@python.org" <python-list@python.org>
Subject Decorator help
Thread-Topic Decorator help
Thread-Index AQHOeCtehAJbpAk0MEWBOkcucFT2Ng==
Date Wed, 3 Jul 2013 22:09:47 +0000
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [172.18.0.4]
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
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.4183.1372889477.3114.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372889477 news.xs4all.nl 15887 [2001:888:2000:d::a6]:37958
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49776

Show key headers only | View raw


I have a set of methods which take args that I decorate twice,

def wrapped(func):
    def wrap(*args, **kwargs):
        try:
            val = func(*args, **kwargs)
            # some work
        except BaseException as error:
            log.exception(error)
            return []
    return wrap

def wrapped_again(length):
    def something(func):
        def wrapped_func(*args, **kwargs):
            values = func(*args, **kwargs)
            # do some work
                return values
        return wrapped_func
    return something

So the methods wrapped are as follows:

@wrapped_again(12)
@wrapped
def class_method(self, **kwargs):
    #....

Is it possible to get the name of the original method (class_method) from within wrapped_func inside wrapped_again?
Thanks!
jlc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Decorator help "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-07-03 22:09 +0000

csiph-web