I have a class with a constructor and a couple of properties
class Foo(object):
def __init__(self, value1):
self._value1 = value1
@property
def value1(self):
return self._value1
@property.setter
def value1(self, value):
assert value == 1
self._value1 = value
Now when I set value1 in on creation of the object the setter is not used. I noticed this because assertions were not called when entering the wrong values.
How can I make the values set in the constructor make use of the setter?
__init__. So no, how would Python know to use the setter forvalue1?