Why is collections.Counter uppercase and collections.defaultdict is not?

こ雲淡風輕ζ 提交于 2021-02-07 20:33:18

问题


Some of the elements in the collections module seem to be uppercase, some other not. Is there a specific rationale behind it?


回答1:


According to this reddit comment

All classes written in python are upper camel case.

All types based on C code are lower. [like the primitives]

namedtuple is a function, thus follows the naming convention of functions. deque and defaultdict are types, (C); Counter and OrderedDict are classes, (Python).



来源:https://stackoverflow.com/questions/33636940/why-is-collections-counter-uppercase-and-collections-defaultdict-is-not

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