Re: Overriding properties - Javaesque property rant

2004-12-12 Thread Kay Schluehr
> There are several ways to fix it. The simplest would be to create a new > property object in CC's definition: > > class CC(C): > def set_value(self, val): > if val < 0: > self.__val = 1 > else: > self.__val = val > value = property(C.get_valu

Re: Overriding properties

2004-12-11 Thread Leif K-Brooks
Nick Patavalis wrote: Why does the following print "0 0" instead of "0 1"? What is the canonical way to rewrite it in order to get what I obviously expect? class C(object): value = property(get_value, set_value) class CC(C): def set_value(self, val): c.value = -1 cc.value =

Overriding properties

2004-12-11 Thread Nick Patavalis
Why does the following print "0 0" instead of "0 1"? What is the canonical way to rewrite it in order to get what I obviously expect? class C(object): __val = 0 def set_value(self, val): if val < 0 : self.__val = 0 else : self.__val = val def get_value(self)