override a property
Robin Becker
robin at reportlab.com
Wed Oct 19 05:16:42 EDT 2005
Steven Bethard wrote:
> Robin Becker wrote:
>
.......
>
> Can you add the object to be observed as another parameter to the add
> method?
>
> py> class ObservableProperty(property):
> ... def __init__(self, *args, **kwargs):
......
> py> A.x.add(b, obs2)
> py> b.x = 7
> obs2: 7
>
> Probably "self._observers" should use some sort of weakref dict instead
> of a regular dict, but hopefully the idea is clear.
>
> STeVe
yes I think this is what Alex is proposing. It probably means abandoning the
class based observers entirely otherwise there would have to be a decision on
whether the instance observers take priority and some argument convention on
whether the class or the instance was being added to.
--
Robin Becker
More information about the Python-list
mailing list