Why True/False is capitalized in Python?

随声附和 提交于 2019-11-28 22:37:55

问题


All members are camel case, right? Why True/False but not true/false, which is more relaxed?


回答1:


From Pep 285:

Should the constants be called 'True' and 'False' (similar to None) or 'true' and 'false' (as in C++, Java and C99)?

=> True and False.

Most reviewers agree that consistency within Python is more important than consistency with other languages.

This, as Andrew points out, is probably because all (most)? built-in constants are capitalized.




回答2:


All of python's built-in constants are capitalized or [upper] CamelCase:




回答3:


Here's a possible explaination:

I see that naming conventions are such that classes usually get named CamelCase. So why are the built-in types named all lowercase (like list, dict, set, bool, etc.)?

Because most of them originally were types and factory functions, not
classes - and a naming convention is not a strong reason to make backwards incompatible changes. A different example: the new builtin type set is based on (altough not exactly equal to) the Set class from the sets module



来源:https://stackoverflow.com/questions/521476/why-true-false-is-capitalized-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!