Why is collections.Counter uppercase and collections.defaultdict is not?
Asked Answered
M

1

5

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

Mogador answered 10/11, 2015 at 18:24 Comment(2)
legacy.python.org/dev/peps/pep-0008/#class-namesRelent
Guess: what are the odds that a piece of code contains a variable called counter (which would shadow that name)? And defaultdict?Margaretamargarete
M
8

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).

Mogador answered 9/12, 2015 at 1:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.