Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45355
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <titanix88@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; '"""': 0.07; 'class,': 0.07; 'differently': 0.07; 'patterns.': 0.07; 'skip:p 60': 0.07; '*args,': 0.09; 'decorator': 0.09; 'derived': 0.09; 'method,': 0.09; 'naturally': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'argument.': 0.16; 'cached': 0.16; 'enough.': 0.16; 'fits': 0.16; 'means:': 0.16; 'name):': 0.16; 'overridden': 0.16; 'subject: \n ': 0.16; 'sugar': 0.16; 'syntactic': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "python's": 0.19; 'skip:p 40': 0.19; 'fit': 0.20; 'cc:addr:python.org': 0.22; 'decorators': 0.24; 'cc:2**0': 0.24; '>': 0.26; '15,': 0.26; 'define': 0.26; 'second': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'quite': 0.32; 'cases': 0.33; 'skip:& 30': 0.33; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'could': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'method': 0.36; 'thanks': 0.36; 'should': 0.36; 'received:209': 0.37; 'easily': 0.37; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'skip:p 20': 0.39; '8bit%:6': 0.40; 'experts': 0.60; 'new': 0.61; 'simply': 0.61; 'name': 0.63; 'such': 0.63; 'natural': 0.68; 'behavior': 0.77; 'subject:skip:A 10': 0.78; 'to:none': 0.92; 'convinced': 0.93; '2013': 0.98 |
| 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:cc:content-type; bh=T8aLMfpDnJ+rSiEuum+xAd+PS0cFEkzPSjut/6qtJFM=; b=apMVUMSmLAVZZ/pg6p0fRj8vsMJlVncEu2aG8cIcVFyrLEvDIQbfupOY4zJgrDlf9e 7HCsGZDfYdAgF4TWlmamAX3uwVBv8rxZk1Keo8n3MH1OopOrqMSfHO6nF7LHCh8A4r1d 5NoFShVTs7ENRIc+/L1GZxIlWWKrYRTaJty1Ly4Wh2RHBqeTcJcFlDVfgqJmcOpAu17r cD3cR5PA7aNxPzd1/9ZVjYW08Xn/utCSBiyhdkGOZkyFKxqocPpQcQ30dDkQWWZUgIL3 rggpg3dMXkiTTZxB3/NzPfYI0gSk9BWZwdZqSO7YxanTvmnmoBD+1llnoaYWH6nfF3f/ rxlA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.193.138 with SMTP id ho10mr39322276pbc.163.1368635890680; Wed, 15 May 2013 09:38:10 -0700 (PDT) |
| In-Reply-To | <87bo8cvkdi.fsf@handshake.de> |
| References | <mailman.1257.1367537690.3114.python-list@python.org> <518302d7$0$29971$c3e8da3$5496439d@news.astraweb.com> <mailman.1265.1367567552.3114.python-list@python.org> <5184aac2$0$29997$c3e8da3$5496439d@news.astraweb.com> <CAJxoosf=ZMK2cVuGdYWH7Hv5tS9pN+ZKzhFvKCerbQuNrK_y5w@mail.gmail.com> <87bo8cvkdi.fsf@handshake.de> |
| Date | Wed, 15 May 2013 22:38:10 +0600 |
| Subject | Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. |
| From | "Mr. Joe" <titanix88@gmail.com> |
| Cc | python-list <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=047d7b15af4317480b04dcc46023 |
| 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.1706.1368635899.3114.python-list@python.org> (permalink) |
| Lines | 91 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1368635899 news.xs4all.nl 15988 [2001:888:2000:d::a6]:37015 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45355 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Wed, May 15, 2013 at 12:15 PM, dieter <dieter@handshake.de> wrote:
>
> If Python would automatically redecorate overridden methods in a derived
> class, I would have no control over the process. What if I need
> the undecorated method or a differently decorated method (an
> uncached or differently cached method, in my case)?
>
On a second thought, I am convinced by your argument.
> Your getter/setter use case can quite easily be solved
> with a class "DelayedMethodAccessor":
>
> class DelayedMethodAccess(object):
> """
> def __init__(self, name): self.__name = name
> def __call__(self, inst, *args, **kw):
> return getattr(inst, self.__name)(*args, **kw)
>
> You can then use:
>
> prop = property(DelayedMethodAccess("<getter_name>"), ...)
>
> Or define a new decorator "property_by_name" and then
> use
>
> prop = property_by_name("<getter_name>", ...)
>
> Of course, this requires that the property name and the getter/setter
names
> differ, but this should be naturally enough.
>
>
> Python's current behavior is very natural once you know that
> decorators are just syntactic sugar and
>
> @<decorator_expression>
> def <f>...
>
> simply means:
>
> def <f>...
> f = <decorator_expressen>(f)
>
> True, this is no perfect fit for all use cases - but
> such a fit (if it existed at all) would have to be so complex
> that only experts could understand it.
Thanks for these really nice patterns. They fits my problem very well.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-03 05:34 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-03 00:20 +0000
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-03 13:52 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-04 06:29 +0000
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-14 21:09 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. dieter <dieter@handshake.de> - 2013-05-15 08:15 +0200
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. "Mr. Joe" <titanix88@gmail.com> - 2013-05-15 22:38 +0600
Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. dieter <dieter@handshake.de> - 2013-05-04 07:56 +0200
csiph-web