-1
I am learning POO in Python and I was in doubt whether I should use advisory methods for all the attributes I include in a class. For example, if I create a class with 20 attributes, in which values will be read and written, I should, by convention, create 40 advisory methods (20 Getters + 20 Setters)?
This answers your question? Pythonic way of defining setters and getters, Give emphasis to this passage Using Property (or getters and setters) to simply save the value as it came and return it as it came, makes no sense
– Augusto Vasques
I added 2 more questions in the blue box above, read to see that the subject goes much beyond what the answers below say (by the way, none should have been accepted, so simplistic that they are - remember that the idea of the site is to have complete answers that serve tb for future visitors - just see the answers of the links indicated above, what we expect - or at least, what we should look for). Although not in Python, the 2 links I added give a more general overview (although in Python there are particularities explained in the first link - about the "pythonic way")
– hkotsubo
Complementing, see also here, to understand that Object Orientation is much more complicated than it seems (besides the links already indicated, you can see more here). Finally, another problem of accepting the answer below is that it disregards the specific context of Python (where nothing is really private), and even spreads it over the Internet, helping to spread misinformation (and has another subtlety about the use of the term attribute, see here)
– hkotsubo
By the way, if you have 20 attributes in the class you may not be delegating responsibilities correctly (and that’s another very important point outside of this topic).
– Woss