max
max

Reputation: 52313

capitalization of library class names

Why do collection.defaultdict and collection.OrderedDict have different capitalizations?

Is there some subtle difference that I should be aware of?

(P3K)

Upvotes: 5

Views: 1845

Answers (3)

Ned Batchelder
Ned Batchelder

Reputation: 375714

The capitalization of the class names is irrelevant, it doesn't signify anything. Except that Python has sometimes grown organically and the standard library doesn't have the same homogenous feel as other large libraries such as the Win32 API or the Java standard library.

Upvotes: 5

mouad
mouad

Reputation: 70039

defaultdict is written in C and pep8 don't apply , in the other hand OrderDict is written in python,

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

reference : source code python2.7

defaultdict  : Modules/_collectionsmodule.c
OrderDict : Lib/collections.py

Upvotes: 1

Stefano Palazzo
Stefano Palazzo

Reputation: 4332

Usually, that is in accordance with good style, classes are capitalised.

def MyClass (object):
    pass

my_instance = MyClass()

like this.

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

Upvotes: 2

Related Questions