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 overridab

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-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

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

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 ex

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 Pyt

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 > > Probabl

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 = '_' + nam

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 m

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 polymo

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 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 proper

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, was

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-17 Thread Bengt Richter
On 17 Oct 2005 11:13:32 -0700, "SPE - Stani's Python Editor" <[EMAIL PROTECTED]> wrote: >No, you can just do it on the fly. You can even create properties >(attributes) on the fly. > >class Dummy: > property = True > >d = Dummy() >d.property = False >d.new = True > a simple attribute is not a p

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 here" comme

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 SPE - Stani's Python Editor
No, you can just do it on the fly. You can even create properties (attributes) on the fly. class Dummy: property = True d = Dummy() d.property = False d.new = True Stani -- SPE - Stani's Python Editor http://pythonide.stani.be -- http://mail.python.org/mailman/listinfo/python-list