Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: =?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?= Newsgroups: comp.lang.python Subject: what is wrong with this property setter Date: Thu, 9 Jun 2016 09:28:34 +0200 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de iSUeQmym/wpB1WWVpisRQA9mby+rW9xop/ZscsdnH1Pw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; '@property': 0.09; 'def': 0.13; 'btw': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'test()': 0.16; 'attribute': 0.18; 'to:name:python- list@python.org': 0.20; 'work,': 0.21; '(most': 0.24; 'subject:what': 0.29; '15,': 0.30; "can't": 0.32; 'skip:_ 10': 0.32; 'class': 0.33; 'traceback': 0.33; 'file': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'skip:p 20': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'charset:iso-8859-2': 0.64; 'subject:this': 0.85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1465457312; bh=V6kCvyJd/lsoEO+xXRuKHcbP8vQiUnr4EZi81zwE8NM=; h=To:From:Subject:Date:From; b=LRsVoYZr6mBtStIDFq4WGcDR7kQnFPLLoB6z9r0KwbyNo0aBmSqo9l7BASme+QpRb f0b1MhVtaBpKaMrJvKT4DXgfTUQnRX0GQBI48xZYKUQdiC2gBhWOJPQbi2MgoXbFWU FBGH5vxW06p4nUyW/R74CvYvKG1BuMG5UKnzenRb7BFoXym7DWdpGaHNYGjaBq+JfF Ra9Z4HqFX+l/lWYf2aX3Tj385J2VvbOrL8J/NPQqKoOB+V1dhkHjlel1wRbBH9zuWf NghFZ77Xvx7E+Hykw+pGRBB6nGiZK25/ExPJT9nnFdXpKwSQx0tXkwVimXiZ36OlPW Xv3sg687d15Dg== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com comp.lang.python:109702 class Test: def __init__(self): self._parent = None @property def parent(self): return self._parent @parent.setter def set_parent(self, new_parent): self._parent = new_parent p, c = Test(), Test() c.parent = p >py -3 test.py Traceback (most recent call last): File "test.py", line 15, in c.parent = p AttributeError: can't set attribute BTW this does work, but it is not that elegant: class Test: def __init__(self): self._parent = None def get_parent(self): return self._parent def set_parent(self, new_parent): self._parent = new_parent parent = property(get_parent, set_parent) p, c = Test(), Test() c.parent = p