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


Groups > comp.lang.python > #109718

Re: what is wrong with this property setter

From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: what is wrong with this property setter
Date 2016-06-09 11:49 +0200
Organization None
Message-ID <mailman.101.1465465810.2306.python-list@python.org> (permalink)
References (1 earlier) <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> <njbe45$b7$1@ger.gmane.org>

Show all headers | View raw


Nagy László Zsolt wrote:

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

If you can read C:

https://hg.python.org/cpython/file/tip/Objects/descrobject.c#l1183
https://hg.python.org/cpython/file/tip/Objects/descrobject.c#l1265

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


Thread

Re: what is wrong with this property setter Peter Otten <__peter__@web.de> - 2016-06-09 11:49 +0200

csiph-web