Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9270 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2011-07-11 11:41 -0600 |
| Last post | 2011-07-11 11:41 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Property setter and lambda question Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-11 11:41 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-07-11 11:41 -0600 |
| Subject | Re: Property setter and lambda question |
| Message-ID | <mailman.913.1310406132.1164.python-list@python.org> |
On Mon, Jul 11, 2011 at 11:21 AM, Anthony Kong <anthony.hw.kong@gmail.com> wrote: > Awesome, Thomas. The trick only works if there is only one leading > underscore in the method names. > The following example works as I expected for the derived class B. > class A(object): > def __init__(self): > self.__not_here = 1 > def _get_not_here(self): > return self.__not_here > def _set_not_here(self, v): > print "I am called" > self.__not_here = v > not_here = property(lambda self: self._get_not_here(), lambda self, v: > self._set_not_here(v)) > class B(A): > def _set_not_here(self, v): > print "version B" > self.__not_here = v It shouldn't. You've still got the name __not_here used in both A and B, so that the B version is setting a different attribute than the A version (_B__not_here vs. _A__not_here).
Back to top | Article view | comp.lang.python
csiph-web