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

Python/PHP/Perl 开发与设计
回复
科学之子
帖子: 2270
注册时间: 2013-05-26 6:58
系统: Debian 9
送出感谢: 846 次
接收感谢: 30 次

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

#1

帖子 科学之子 » 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里可以用指针乱玩一样
科学之子
帖子: 2270
注册时间: 2013-05-26 6:58
系统: Debian 9
送出感谢: 846 次
接收感谢: 30 次

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

#2

帖子 科学之子 » 2016-09-06 12:36

This can even be useful in special circumstances, such as in the debugger.
貌似是为了方便用户调试或观察标准库之类的模块?
回复

回到 “Python/Php/Perl”