Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9269
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.054 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'derived': 0.09; 'am,': 0.13; 'wrote:': 0.15; '(when': 0.16; 'input,': 0.16; 'it).': 0.16; 'lambda': 0.16; 'mon,': 0.16; 'def': 0.16; 'subject:question': 0.21; 'modify': 0.22; 'header:In-Reply-To:1': 0.22; 'convenience': 0.23; 'pair': 0.23; 'bit': 0.28; 'message-id:@mail.gmail.com': 0.28; 'classes': 0.30; 'anthony': 0.30; 'version': 0.30; 'thanks': 0.31; 'class': 0.31; 'to:addr:python-list': 0.34; 'there': 0.34; 'normally': 0.34; 'skip:b 40': 0.34; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'easier': 0.39; 'allows': 0.39; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'your': 0.60; '11,': 0.68; 'kong': 0.84; 'self:': 0.84; 'subject:Property': 0.84; 'value):': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ZmJm39+jqVXuIHF8e/p0NT5L13z3VLBbt3QpouOIUhY=; b=U1LLvTZGGGq78Igwx+CcU5xSLgU7CisFouIIaBmZi/0RcU/Q8rd8hPBxuoqkfhd/tc ZZIhzs+AfgquuOcAbY7rMn4JmakEfS/zWmP7zEVNsoEgypFXWYcmqpxi4uCq1ZzBLexg 5qWCPxxmJD/K7bYkUfxWStyr7B4ud3tVifCsY= |
| MIME-Version | 1.0 |
| In-Reply-To | <CAAyd8cnypAUDE4A95YAdpppWp7yCD9cTKCFhUxqvfEUHjxczBQ@mail.gmail.com> |
| References | <CAAyd8cncdj0CStxZdWDcpWCjjEd7WVA=m-CQ0H988zuv52SwMg@mail.gmail.com> <4E1B238B.7050607@jollybox.de> <CAAyd8cnypAUDE4A95YAdpppWp7yCD9cTKCFhUxqvfEUHjxczBQ@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 11 Jul 2011 11:35:05 -0600 |
| Subject | Re: Property setter and lambda question |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.912.1310405736.1164.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1310405736 news.xs4all.nl 21828 [2001:888:2000:d::a6]:33490 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:9269 |
Show key headers only | View raw
On Mon, Jul 11, 2011 at 10:53 AM, Anthony Kong
<anthony.hw.kong@gmail.com> wrote:
> Thanks again for your input, Thomas.
> I normally prefer
> not_here = property(lambda self: self.__get_not_here(), lambda self, v:
> self.__set_not_here(v))
> than
> not_here = property(__get_not_here, __set_not_here)
> Because it allows me to have a pair getter/setter (when there is a need for
> it). Use of lambda there is ensure derived class of A can provide their
> custom version of getter/setter.
The .setter convenience method also makes it a bit easier for derived
classes to modify getters and setters:
class Base(object):
def get_my_property(self):
return self._my_property
def set_my_property(self, value):
self._my_property = value
my_property = property(get_my_property, set_my_property)
class Derived(Base):
def set_my_property(self, value):
super(Derived, self).set_my_property(convert(value))
my_property = Base.my_property.setter(set_my_property)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Property setter and lambda question Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-11 11:35 -0600
csiph-web