2

While reading Python Cookbook I came across these two lines:

    from collections import OrderedDict
    from collections import defaultdict

Now see the naming conventions of the functions in these lines. The first one has CamelCase and the second one has all small caps.

Why are these two named in different style?

I have researched about it on the Internet and frankly I've not found what I was looking for.

  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask – gnat Dec 30 '15 at 8:38
  • Now i Know why I got downvoted. So , I've edited my question. Hope someone answers Soon. – SloppyJoe Dec 30 '15 at 10:02
1

In Python, builtin types are named in lowercase (str, int, dict), while custom types (the classes you write yourself) use camel case. Extra types that are included in the standard library until 2.6 are named as if they were builtin types. Later inclusions (2.7 and 3.*) are named as if they were custom types. I don't know why the change, but they kept the old names for the existing types because of backwards compatibility.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.