Some of the elements in the collections
module seem to be uppercase, some other not. Is there a specific rationale behind it?
Asked
Active
Viewed 496 times
3
-
1http://legacy.python.org/dev/peps/pep-0008/#class-names – 301_Moved_Permanently Nov 10 '15 at 18:26
-
Guess: what are the odds that a piece of code contains a *variable* called `counter` (which would shadow that name)? And `defaultdict`? – Bakuriu Nov 10 '15 at 18:39
1 Answers
3
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
anddefaultdict
are types, (C);Counter
andOrderedDict
are classes, (Python).