Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python:': 0.05; '"""': 0.07; '(sorry,': 0.09; 'subclasses': 0.09; 'syntax': 0.11; 'wrote:': 0.15; '(when': 0.16; '@property': 0.16; 'lambda': 0.16; 'received:192.168.1.40': 0.16; 'reminding': 0.16; 'val': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'def': 0.16; 'exists': 0.19; 'exists.': 0.19; "haven't": 0.21; 'subject:question': 0.21; 'cc:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'cheers': 0.23; 'somewhere': 0.23; 'saying': 0.26; "i'm": 0.27; 'problem': 0.29; 'cc:addr:python.org': 0.30; 'anthony': 0.30; 'email name:': 0.30; 'thanks': 0.31; 'class': 0.31; 'translate': 0.31; 'this.': 0.31; 'ps:': 0.32; 'does': 0.32; 'header:User-Agent:1': 0.34; 'example,': 0.35; 'but': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'received:192.168.1': 0.39; 'might': 0.39; 'where': 0.40; 'your': 0.60; 'received:62': 0.67; 'works,': 0.68; "doesn't,": 0.84; 'from:addr:t': 0.84; 'kong': 0.84; 'self:': 0.84; 'subject:Property': 0.84 Date: Mon, 11 Jul 2011 19:06:05 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: Anthony Kong Subject: Re: Property setter and lambda question References: <4E1B238B.7050607@jollybox.de> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310403973 news.xs4all.nl 21842 [2001:888:2000:d::a6]:42868 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9265 # On 07/11/2011 06:53 PM, Anthony Kong wrote: # But decorator! Of course! Thanks for reminding me this. # # In your example, where does '@not_here' come from? (Sorry, this syntax # is new to me) class A(object): def __init__(self): self.not_here = 1 @property def not_here(self): return self.__not_here @not_here.setter def not_here(self, val): self.__not_here = val """ Let's translate that to non-decorator Python: """ class A(object): def __init__(self): self.not_here = 1 def _(self): return self.__not_here not_here = property(_) del _ def _(self, val): self.__not_here = val not_here = not_here.setter(_) del _ """ @not_here.setter exists because not_here.setter exists. not_here exists since we set it (when the getter/property was set). Cheers Thomas PS: are you sure the lambda self: self.__foo() trick works, with subclasses or otherwise? I haven't tested it, and I'm not saying it doesn't, but I have a feeling double-underscore name mangling might be a problem somewhere down the line? """