Re: override a property

2005-10-22 Thread Robin Becker
Alex Martelli wrote: .. If (e.g.) __set__ needs to behave differently when applied to certain instances rather than others, then it had better be messed with (overridden) compared to property.__set__ since the latter has no such proviso. Of course, your architecture as sketched below

Re: override a property

2005-10-22 Thread Kay Schluehr
Robin Becker wrote: Kay Schluehr wrote: Robin Becker wrote: I thought that methods were always overridable. In this case the lookup on the class changes the behaviour of the one and only property. How can something be made overridable that is actually overridable? I didn't know

Re: override a property

2005-10-21 Thread Robin Becker
Kay Schluehr wrote: Robin Becker wrote: I thought that methods were always overridable. In this case the lookup on the class changes the behaviour of the one and only property. How can something be made overridable that is actually overridable? I didn't know how to better express the

Re: override a property

2005-10-21 Thread Bengt Richter
On Tue, 18 Oct 2005 08:00:51 +, Robin Becker [EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? I

Re: override a property

2005-10-21 Thread Alex Martelli
Robin Becker [EMAIL PROTECTED] wrote: ... in answer to Bengt Bruno here is what I'm sort of playing with. Alex suggests class change as an answer, but that looks really clunky to me. I'm not sure what Changing class is indeed 'clunky', though it might have been necessary depending on how

Re: override a property

2005-10-20 Thread Kay Schluehr
Robin Becker wrote: I thought that methods were always overridable. In this case the lookup on the class changes the behaviour of the one and only property. How can something be made overridable that is actually overridable? I didn't know how to better express the broken polymorphism of

Re: override a property

2005-10-19 Thread Robin Becker
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

Re: override a property

2005-10-18 Thread Robin Becker
Bruno Desthuilliers wrote: Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? I mean property here. My aim was to create an ObserverProperty class

Re: override a property

2005-10-18 Thread bruno modulix
Robin Becker wrote: Bruno Desthuilliers wrote: Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? I mean property here. Ok, wasn't sure... And sorry

Re: override a property

2005-10-18 Thread Alex Martelli
Robin Becker [EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? I mean property here. My aim

Re: override a property

2005-10-18 Thread Robin Becker
bruno modulix wrote: . Could you elaborate ? Or at least give an exemple ? . in answer to Bengt Bruno here is what I'm sort of playing with. Alex suggests class change as an answer, but that looks really clunky to me. I'm not sure what Alex means by A better design might be to

Re: override a property

2005-10-18 Thread Kay Schluehr
Robin Becker wrote: Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker It is possible to decorate a method in a way that it seems like property() respects overridden methods. The decorator cares

Re: override a property

2005-10-18 Thread Robin Becker
Kay Schluehr wrote: Robin Becker wrote: Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker It is possible to decorate a method in a way that it seems like property() respects overridden methods

Re: override a property

2005-10-18 Thread Steven Bethard
Robin Becker wrote: ## my silly example class ObserverProperty(property): def __init__(self,name,observers=None,validator=None): self._name = name self._observers = observers or [] self._validator = validator or (lambda x: x) self._pName = '_' + name

override a property

2005-10-17 Thread Robin Becker
Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list

Re: override a property

2005-10-17 Thread Bruno Desthuilliers
Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? -- http://mail.python.org/mailman/listinfo/python-list

Re: override a property

2005-10-17 Thread Bengt Richter
On Mon, 17 Oct 2005 18:52:19 +0100, Robin Becker [EMAIL PROTECTED] wrote: Is there a way to override a data property in the instance? Do I need to create another class with the property changed? How do you need to override it? Care to create a toy example with a wish I could override action