Python中避免使用getter和setter的原因

Cool link: Python is not
Java
 :)

In Java, you have to use getters and setters because using public fields
gives you no opportunity to go back and change your mind later to using
getters and setters. So in Java, you might as well get the chore out of
the way up front. In Python, this is silly, because you can start with a
normal attribute and change your mind at any time, without affecting any
clients of the class. So, don’t write getters and setters.

plus setters/getters add performance cost, especially in Python.


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!