3 ms·
I understand your point. I think this is partly related to the fact that instance attributes are public by default and do not require accessor or mutator method
by meowface 8y ago
I understand your point. I think this is partly related to the fact that instance attributes are public by default and do not require accessor or mutator methods (though you can easily create them with the @property decorator) and partly due to the fact that Python is a very dynamic language.
You can make instance variables "culturally private" by pretending the variable name with a single underscore, and you can name-mangle (to make it effectively private, unless someone really goes out of their way) with double underscores, but I know that's annoying to do for most/all variables and that making them private by default has advantages.
Python is just not as strict a language as Java, Swift, C#, etc. That has advantages and disadvantages.
Personally, this hasn't generally been an issue for me, because I've rarely directly modified instance variables in my own code unless I'm intentionally doing something really "meta", and it's not a pattern I've seen much of in other codebases.