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