Why did someone from ##learnpython just tell me to stop using CamelCase?

One of python's greatest strengths as a language is its clarity, and the consensus about what clarity in python means. Mainly, this boils down to consistency. Keeping your code consistent means you (and others) can read it and debug it more easily. In light of that, why not just "consistently" use CamelCase for your variable names?

Well, the python standard library uses snake_case, and if your code uses the standard library (and it does) any project you write in python will not only be in conflict with the community-at-large's standards, but it will also be in conflict with its self. Short of re-writing the stdlib entirely in CamelCase, this is unavoidable.

1. Uh, bro, the threading module and logging module in the stdlib have camelCase.

Yeah, but they're bloody ancient. PEP8 explicitly mentions how they are old as hell. If you happen to find yourself writing code for the threading module in python's stdlib, knock yourself out with camelCase.

2. Well, it's not just the stdlib. PyQt uses it too, and that's a big accepted 3rd party lib! Ha!

PyQt is such a thin wrapper around c++ that it doesn't even have its own docs. It's in CamelCase so that they didn't have to write any, and could just throw up a signpost to the c++ docs. It's actually kind of sad, but nobody in their right mind would want to rewrite all of that, so we can't blame them.

3. Other languages like C, and even modern hipster Haskell use camelCase!

There's nothing innately wrong with it as a way of writing variable names, it's just not the way to do things in python. Sometimes you have to leave your baggage at the door and deal with it.

4. But...


5. So when *can* I use CamelCase?

In python, all class names should be in CamelCase.

Here's a link to the relevant PEP8 section.