为什么 collections.Counter 是大写而 collections.defaultdict 不是?
Why is collections.Counter uppercase and collections.defaultdict is not?
collections
模块中的某些元素似乎是大写的,而另一些则不是。它背后有特定的理由吗?
根据 this reddit 评论
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).
collections
模块中的某些元素似乎是大写的,而另一些则不是。它背后有特定的理由吗?
根据 this reddit 评论
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
anddefaultdict
are types, (C);Counter
andOrderedDict
are classes, (Python).