分页: 1 / 1

为什么Python那么依靠"convention"?

发表于 : 2016-09-06 12:29
科学之子
为什么Python那么依靠"convention"?
https://docs.python.org/3.4/tutorial/cl ... -variables
“Private” instance variables that cannot be accessed except from inside an object don’t exist in Python. However, there is a convention that is followed by most Python code: a name prefixed with an underscore (e.g. _spam) should be treated as a non-public part of the API (whether it is a function, a method or a data member). It should be considered an implementation detail and subject to change without notice.
尤其是它还自称是"very-high-level language"
虽然确实有一些高级语言的特性,但是这么依赖约定...有种用C的感觉...
感觉就好像C里可以用指针乱玩一样

Re: 为什么Python那么依靠"convention"?

发表于 : 2016-09-06 12:36
科学之子
This can even be useful in special circumstances, such as in the debugger.
貌似是为了方便用户调试或观察标准库之类的模块?