I have a big issue, I'm new with @property and setter but I need to use them for a University Assignment: my problem is that the setters are always bypassed by the getters and also, when i try to pass an argument to the setter, it doesn't work:
class DumbClass(): def __init__(self, classParam): self.ciao = classParam @property def getCiao(self): return self.ciao @getCiao.setter def setCiao(self,dummy): self.ciao = dummy Then, when i call it I have either:
pizzo = DumbClass('getter') pozza = pizzo.getCiao('setter') print(pizzo.ciao, pozza) ---------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-18-78a6b4607757> in < module>() 1 pizzo = DumbClass('getter') ----> 2 pozza = pizzo.getCiao('setter') 3 print(pizzo.ciao, pozza) TypeError: 'str' object is not callable Or, if I don't pass any arguments:
pizzo = DumbClass('getter') pozza = pizzo.getCiao print(pizzo.ciao, pozza) ---------------------------------------------------------------------- getter getter I can I make the setter to be called?
getCiao, notciao.ciaois still just an attribute.