Re: [Tutor] calling setters of superclasses

2010-12-22 Thread Matt Gregory
On 12/18/2010 2:06 AM, Peter Otten wrote: I don't think /how/ you are trying it is stupid though I'm not so sure about /what/ . Thank you all for very helpful suggestions. It took me a while to chew on this before I could respond. I learned a lot about descriptors and their interactions wit

Re: [Tutor] calling setters of superclasses

2010-12-20 Thread Alan Gauld
"Steven D'Aprano" wrote I don't use properties in Python very often (hardly ever in fact) and I've never used @setter so there may be naming requirements I'm not aware of. But in general I'd avoid having two methods with the same name. That's generally good advice, since one will over-write

Re: [Tutor] calling setters of superclasses

2010-12-20 Thread Steven D'Aprano
Alan Gauld wrote: "Gregory, Matthew" wrote class PositiveX(object): def __init__(self): @property def x(self): @x.setter def x(self, val): I don't use properties in Python very often (hardly ever in fact) and I've never used @setter so there may be naming requirements I'm not

Re: [Tutor] calling setters of superclasses

2010-12-18 Thread Hugo Arts
On Sat, Dec 18, 2010 at 11:06 AM, Peter Otten <__pete...@web.de> wrote: > > I don't think /how/ you are trying it is stupid though I'm not so sure about > /what/ . > > I didn't get it to work with super() either, so here's Plan B till someone > is going to enlighten both of us: > By no means a sol

Re: [Tutor] calling setters of superclasses

2010-12-18 Thread Peter Otten
Gregory, Matthew wrote: > Hi all, > > Consider the following classes where PositiveX should constrain the > attribute _x to be positive and SmallX should further constrain the > attribute _x to be less than 10. > > class PositiveX(object): > def __init__(self): > self._x = 1 > @p

Re: [Tutor] calling setters of superclasses

2010-12-17 Thread Alan Gauld
"Gregory, Matthew" wrote class PositiveX(object): def __init__(self): @property def x(self): @x.setter def x(self, val): I don't use properties in Python very often (hardly ever in fact) and I've never used @setter so there may be naming requirements I'm not aware of. But i

[Tutor] calling setters of superclasses

2010-12-17 Thread Gregory, Matthew
Hi all, Consider the following classes where PositiveX should constrain the attribute _x to be positive and SmallX should further constrain the attribute _x to be less than 10. class PositiveX(object): def __init__(self): self._x = 1 @property def x(self): return sel