Capitalization of library class names

Why do collection.defaultdictthey collection.OrderedDicthave different capital letters?

Is there any subtle difference I should know about?

(P3K)

+3
source share
3 answers

The capitalization of class names does not matter; it does not mean anything. Except that Python sometimes grows organically, and the standard library does not have the same uniform feel as other large libraries, such as the Win32 API or the standard Java library.

+4
source

Usually this is in line with good style; classes are capitalized.

def MyClass (object):
    pass

my_instance = MyClass()

like this.

You should read this document: http://www.python.org/dev/peps/pep-0008/

+2

defaultdict is written in C and pep8 is not applied, on the other hand OrderDict is written in python,

you can read the C code norm for a Python C implementation here: PEP 7

reference: python2.7 source code

defaultdict  : Modules/_collectionsmodule.c
OrderDict : Lib/collections.py
+2
source

Source: https://habr.com/ru/post/1771705/


All Articles