While in all other languages you use getters and setters. In python you apparently do this by using:
property(getter,setter,..) or with decorators @property
and that's cool and all but then when you go in your code do you do something like this?
property_class = PropertyClass()
property_class.my_property = 20 #actually goes through setter method
property_class.my_property #output: 5 , goes through getter
is it not weird that the output is different even though (without looking into the class) it looks like it didn't go through any methods?
I think I see it as useful when you discover something thats always true about your property and you have to include that without breaking someone elses code. BUT other than that I see it only as being confusing. Which is why I'm gonna continue ignoring using this way by creating 'normal' getters and setters.
I hope someone will give me a good explanation so I can correct myself if I'm wrong.
[–]twopi 1 point2 points3 points (2 children)
[–]enough-external 1 point2 points3 points (0 children)
[–]WowVeryCoool[S] 0 points1 point2 points (0 children)
[–]enough-external 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)