When writing your scripts, there are a few naming conventions to observe that are common to scripting and programming. These conventions are more of guidelines and best practices than hard rules, which means that you will hear opinions on both sides. As scripting is a form of art, you will see examples that rebut these suggestions, but following them will improve readability.
Most of the suggestions here were borrowed from the style guide for Python, which can be found at http://legacy.python.org/dev/peps/pep-0008/, and follow-on style guides.
If you see specifics here that do not directly match this guide, keep in mind that all assessors develop habits and styles that differ. The trick is to incorporate as many of the best practices as possible while not impacting the speed and quality of development.
Classes typically begin with an uppercase letter, and the rest of the first word is lowercase. Each word after that starts with an uppercase letter as well. As such, if you see a defined reference being used and it begins with an uppercase letter, it is likely a class or module name. No spaces or underscores should be used between the words used to define a class, though people typically forget or break this rule.
When you are developing functions, remember that the words should be lowercase and separated by underscores.
Variables and instances should be lowercase with underscores separating the words, and if they are private, they must lead with two underscores. Public
and Private
variables are common in major programming languages, but in Python, they are not truly necessary. If you would like to emulate the functionality of a private
variable in Python, you can lead the variable with __
to define it as private. A private member's major benefit in Python is the prevention of namespace clashing.