Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.061 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'subject:help': 0.08; 'decorator': 0.09; 'methods,': 0.09; 'def': 0.12; 'appreciated!': 0.16; 'args.': 0.16; 'received:172.18.0': 0.16; 'to:name:python- list@python.org': 0.22; 'class': 0.32; 'thanks!': 0.32; 'skip:_ 10': 0.34; 'clear': 0.37; 'to:addr:python-list': 0.38; 'guidance': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'received:unknown': 0.61; 'making': 0.63; 'within': 0.65; 'hoping': 0.75; 'decorate': 0.84 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=SNukfclIDc7GjKe+LHtSoPUBJt/gHPuqMk7EpfoOdzs= c=1 sm=1 a=P90J6pEA2ccA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=I1x7mEo_DWEziW7U5iAA:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: "python-list@python.org" Subject: Decorator help Thread-Topic: Decorator help Thread-Index: AQHOKyIIGDgWeiUVSEqnSm5Oit30Vg== Date: Wed, 27 Mar 2013 19:49:54 +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="iso-8859-1" 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364413867 news.xs4all.nl 6901 [2001:888:2000:d::a6]:40087 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42036 I have a class=A0which=A0sets up some class vars, then several methods that= are passed in data=0A= and do work=A0referencing the class vars.=0A= =0A= =0A= I want to decorate these methods, the decorator needs access to the class v= ars, so I thought=0A= about making the decorator its own class and allowing it to accept args.=0A= =0A= =0A= I was hoping to do all the work on=A0in_data from within the decorator, whi= ch requires access=0A= to several=A0MyClass vars. Not clear on the syntax/usage with this approach= here, any guidance=0A= would be greatly appreciated!=0A= =0A= =0A= Class MyDecorator(object):=0A= =0A= =A0 =A0 def __init__(self, arg1, arg2):=0A= =A0 =A0 =A0 =A0 self.arg1=A0=3D=A0arg1=0A= =A0 =A0 =A0 =A0 self.arg2=A0=3D=A0arg2=0A= =A0 =A0 ...=0A= =0A= =0A= Class MyClass(object):=0A= =A0 =A0 def __init__(self):=0A= =A0 =A0 =A0 =A0 self.var_a =3D ....=0A= =A0 =A0 ....=0A= =A0 =A0 @MyDecorator(...)=0A= =A0 =A0 def meth_one(self, in_data):=0A= =A0 =A0 =A0 =A0 ...=0A= =0A= =0A= Thanks!=0A= jlc=