Path: csiph.com!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: Re: what is wrong with this property setter Date: Thu, 9 Jun 2016 11:15:12 +0200 Lines: 23 Message-ID: References: <897fc4dd-5018-b6ec-0723-be7322717e38@shopzeus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de J2r5wWoZVW/RxH5mRqjE4AQw41/uXMd7/MhqcdgBh2aA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'works.': 0.07; 'elegant,': 0.09; ':-)': 0.12; 'def': 0.13; '...)': 0.16; 'cleaner': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sugar': 0.16; 'syntactic': 0.16; 'basically': 0.18; 'creates': 0.18; 'to:name :python-list@python.org': 0.20; 'logical': 0.22; 'header:In-Reply- To:1': 0.24; 'define': 0.27; 'subject:what': 0.29; 'could': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'skip:p 20': 0.38; 'thank': 0.38; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'more.': 0.63; 'you.': 0.64; 'believe': 0.66; 'practice.': 0.66; 'alternative.': 0.84; 'subject:this': 0.85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1465463709; bh=ywRh5Dt/dKDF9x6yEVRNYO1MJ0R4b2c40zS0SJrQ0O4=; h=Subject:To:References:From:Date:In-Reply-To:From; b=EXYhFeIcG9Vpe5GlOSS01sYmtLwJD0QdRPrNlBE6XlO4kioQ7fiSTQkAdw69WiC/r tD2G4oi/VSHb/WeXACa1qodDafda6qu+lIy1PrFwvBHJeysNW9rVgCnXpd6JDmBESd IHZFEUD0SVufVQX2x8TX9kkF6kzTbko9HVZHrOJBIBgHFO3tInNGKwOF3n3u04iMUW 7iAxiRn5V8lgs5+pfVb7NBtso+NDmRZ0UKq64GU20kMtqB2H7roituiLaRKq8h5ll7 ccPyK+mfuwmtD+rxdZNsMSpjs3nblB/S4qW6xCYHewqNSy6w/LHHfTQFwUESD97TfS 7j/PJlJ+NE1Tg== In-Reply-To: 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: <897fc4dd-5018-b6ec-0723-be7322717e38@shopzeus.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109714 >> Yes, and more. That property will also have a get method! Is it >> intentional? > It's a logical effect of how the setter() method works. The above is > syntactic sugar for > > def set_parent(...): > ... > set_parent = parent.setter(set_parent) > > and parent.setter() creates a new property basically like this > > def setter(self, fset): > return property(self.fget, fset, ...) This I could not find, because property is a built-in. But I believe you. :-) > > Not very elegant, but I don't see a cleaner alternative. It can be used to define an alternative setter for the same property, but it is bad practice. Thank you for the clarification.