Naming styles
The different naming styles used in Python are:
- CamelCase
- mixedCase
- UPPERCASE, and UPPER_CASE_WITH_UNDERSCORES
- lowercase and lower_case_with_underscores
- _leading and trailing_ underscores, and sometimes __doubled__ underscores
Lowercase and uppercase elements are often a single word, and sometimes a few words concatenated. With underscores, they are usually abbreviated phrases. Using a single word is better. The leading and trailing underscores are used to mark the privacy and special elements.
These styles are applied to:
- Variables
- Functions and methods
- Properties
- Classes
- Modules
- Packages
Variables
There are two kinds of variables in Python:
- Constants
- Public and private variables
Constants
For constant global variables, an uppercase with an underscore is used. It informs the developer that the given variable represents a constant value.
Note
There are no real constants in Python like those in C++, where const
can be used. You can change the value of any variable. That's why Python uses a...