Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42354
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'yet.': 0.04; 'variables': 0.07; 'subject:help': 0.08; 'ambiguity': 0.09; 'references.': 0.09; 'repeated': 0.09; 'python': 0.11; '*class': 0.16; 'attributes,': 0.16; 'called.': 0.16; 'definition.': 0.16; 'normally,': 0.16; 'received:172.18.0': 0.16; ':-)': 0.16; 'do.': 0.18; 'thorough': 0.19; 'to:name:python-list@python.org': 0.22; 'decorators': 0.24; 'stick': 0.24; "haven't": 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'see,': 0.30; 'work.': 0.31; 'enjoyed': 0.31; 'loads': 0.31; 'ordinary': 0.31; 'class': 0.32; 'know.': 0.32; 'stuff': 0.32; 'regular': 0.32; 'run': 0.32; "can't": 0.35; 'classes': 0.35; 'but': 0.35; 'functions.': 0.36; 'done': 0.36; "didn't": 0.36; 'method': 0.36; 'thanks': 0.36; "i'll": 0.36; 'example,': 0.37; 'being': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:unknown': 0.61; 'utilize': 0.61; 'first': 0.61; 'more': 0.64; 'here': 0.66; 'fantastic': 0.74; 'other.': 0.75; 'and\xa0': 0.84; 'guessed': 0.84; 'guideline': 0.84; 'is\xa0': 0.84; 'yet?': 0.84 |
| X-Cloudmark-SP-Filtered | true |
| X-Cloudmark-SP-Result | v=1.1 cv=SNukfclIDc7GjKe+LHtSoPUBJt/gHPuqMk7EpfoOdzs= c=1 sm=1 a=CRTDazI5n6YA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=0fULB5yaFHI6-8pY3sMA:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 |
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: Decorator help |
| Thread-Topic | Decorator help |
| Thread-Index | AQHOK0L9GDgWeiUVSEqnSm5Oit30Vpi+7nsc |
| Date | Sun, 31 Mar 2013 00:06:01 +0000 |
| References | <515380f4$0$29998$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <515380f4$0$29998$c3e8da3$5496439d@news.astraweb.com> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [172.18.0.200] |
| 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 <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.4008.1364688371.2939.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1364688371 news.xs4all.nl 6982 [2001:888:2000:d::a6]:51289 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:42354 |
Show key headers only | View raw
> When you say "class vars", do you mean variables which hold classes? You guessed correctly, and thanks for pointing out the ambiguity in my references. > The one doesn't follow from the other. Writing decorators as classes is > fairly unusual. Normally, they will be regular functions. I see, this I didn't know. I'll stick to this guideline now. > A more complicated case is where you need to do some pre-processing, and > you *don't* want that calculation repeated every time the method is > called. Decorators are fantastic for that case too, but here you cannot > access instance attributes, since the instance doesn't exist yet. But you > can access *class attributes*, as more-or-less ordinary local variables > *inside* the class definition. Here's a working sketch of the sort of > thing you can do. Copy and paste the following into a Python interactive > session, and then see if you can follow what is being done when. > Is your mind boggled yet? :-) Steven, That was some of the coolest stuff I have seen a while. I had to wait until I had enough time to actually run this through and utilize it my own work. I haven't enjoyed Python this much since I first started using it. Can't thank you enough for the time and thorough example, that imparted loads of insight. jlc
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Decorator help "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-03-27 19:49 +0000
Re: Decorator help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-27 23:29 +0000
Re: Decorator help Jason Swails <jason.swails@gmail.com> - 2013-03-27 22:38 -0400
Re: Decorator help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-28 04:58 +0000
RE: Decorator help "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-03-31 00:06 +0000
csiph-web