I try to fit good oop behaviour in my code and was wondering the following:
I generally have this kind of a class design:
class MyClass():
def __init__(self,arg1):
self.arg1 = arg1
@property
def arg1(self):
return _arg1
@arg1.setter
def arg1(self, value):
self._arg1 = value
If I now write a function which has a dict and uses this dict for setting class attributes:
def set_my_dict(self):
argdict = {'arg1':4}
for k, v in argdict:
setattr(self, k, v)
Does this setattr
call, in this situation, the setter for possible type checks etc?