Closed Smiley32 closed 4 years ago
Since we already have a setget
defined for the property though, would it be better to use self.target_path = ...
instead of set_target_path(...)
? That way, if the setter is ever changed to something else, you don't then also have to update it a secondary location where the assignment was meant to happen. self.<property> =
will simulate an external access to manually trigger the setter on the property.
Of course it's better to use the setget
if we can. But as mentioned in the documentation, self.target_path = ...
won't call the setter since the instruction is inside the class
Whenever the value of variable is modified by an external source (i.e. not from local usage in the class), the setter function (setterfunc above) will be called.
Yes, but prefixing the property access with self.
actually forces a simulation of an external access. :-) I invite you to give it a try. Unless something changed from 3.1 to 3.2...
Oh, I'm sorry. You're totally right. So yes, it would be better to use that instead of directly the setter I think.
Not really a big deal which one we use ultimately. I'm gonna merge.
As it's within the class, setget doesn't work, and target won't be set, so we should use the setter explicitly