When building getter and setter methods in Python, I understand you can define attributes with @property
and @x.setter
or define the methods __getattr__
and __setattr__
. Both ways appear the same to the user as in it replaces directly accessing attributes with getter and setter methods. But it seems like with @property
you can define getters and setters for each attribute while with __getattr__
and __setattr__
you can only define one getter and setter for the class. So is there any reason to not use @property
?
EDIT: Not really sure how those other questions answer mine? The upvoted question answers how to replace using __setattr__
and using it correctly which is not my question. The other question is downvoted and closed for lacking focus, and I was hoping this question improved upon that one.