Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'incompatible': 0.07; 'nicely': 0.07; 'code"': 0.09; 'decorator': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'works.': 0.09; 'python': 0.11; 'def': 0.12; 'backward': 0.16; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'surprises': 0.16; 'syntactic': 0.16; 'subject:python': 0.16; 'language': 0.16; 'code.': 0.18; 'solution.': 0.20; 'work,': 0.20; 'header:User-Agent:1': 0.23; '(such': 0.24; 'decorators': 0.24; 'together.': 0.24; 'developers': 0.25; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'correct': 0.29; 'towards': 0.31; 'writes:': 0.31; 'allows': 0.31; 'compatible': 0.32; 'problem': 0.35; 'subject:with': 0.35; 'problem.': 0.35; 'but': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'should': 0.36; 'two': 0.37; 'level': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'easy': 0.60; 'solve': 0.60; 'received:217': 0.63; 'behavior': 0.77; 'subject:skip:A 10': 0.78; 'hate': 0.91; 'hand,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: dieter Subject: Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError. Date: Sat, 04 May 2013 07:56:22 +0200 References: <518302d7$0$29971$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e08eb0.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:FRjldeDA6XbDLIqMq0hUQ2p3sBg= 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367646997 news.xs4all.nl 15933 [2001:888:2000:d::a6]:46844 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44704 "Mr. Joe" writes: > ... > Then I came to know that 'property' does not play well > with polymorphic code. :( Can you elaborate? I like "polymorphic code" and decorators (such a "property") never met a problem with the two working nicely together. > I resorted to some lambda hacks learned from > stackoverflow.com to solve the problem. I know that it's the correct way > for decorators to work, but still, it would be nice to have a language > level solution. There are two approaches: change the language or learn how the language works. I am very happy that the Python developers try hard to retain backward compatible and, consequently, are very reluctant towards language changes. I would hate should the decorator behavior change in an incompatible way. On the other hand, decorators are very easy to understand: they are just syntactic sugar: @ def f(...): ... is equivalent to: def f(...): ... f = (f) The "property" decorator uses an additional concept: "descriptor"s. A "descriptor" allows you to customize attribute access. These two concepts graped, the "property" decorator should no longer cause surprises -- even in "polymorphic code".