Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109714

Re: what is wrong with this property setter

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Nagy László Zsolt <gandalf@shopzeus.com>
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 <mailman.98.1465463711.2306.python-list@python.org> (permalink)
References <bc685f14-106c-4d3f-38f9-262e05b896d7@shopzeus.com> <njb7oj$u9s$1@ger.gmane.org> <bb9a1f16-e88b-7936-2826-a6def0bdb309@shopzeus.com> <njbb80$lfv$1@ger.gmane.org> <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 <gandalf@shopzeus.com>
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 <njbb80$lfv$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <897fc4dd-5018-b6ec-0723-be7322717e38@shopzeus.com>
X-Mailman-Original-References <bc685f14-106c-4d3f-38f9-262e05b896d7@shopzeus.com> <njb7oj$u9s$1@ger.gmane.org> <bb9a1f16-e88b-7936-2826-a6def0bdb309@shopzeus.com> <njbb80$lfv$1@ger.gmane.org>
Xref csiph.com comp.lang.python:109714

Show key headers only | View raw


>> 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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: what is wrong with this property setter Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-09 11:15 +0200

csiph-web