Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109714
| From | Nagy László Zsolt <gandalf@shopzeus.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: what is wrong with this property setter |
| Date | 2016-06-09 11:15 +0200 |
| 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> |
>> 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
Re: what is wrong with this property setter Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-09 11:15 +0200
csiph-web