Naming
Underscores
One at the Start
Using one underscore at the start of a name will make that object protected.
Example: _var
Two at the Start
Using two underscores at the start of the name will make that object class-private.
Example: __var
Two at the Start and Two at the End
Two at the start and the end is usually saved for built-in classes and has no real use outside of them.
Example: __var__
There are build-in variables and methods following this pattern, such as __init__
.
Variables
Variables in Python are typically all lowercase, with words separated by underscores. This is commonly called "Snake Case". Variables can not begin with numbers, but can include numbers after the fact. A typical name would be as follows: my_var
.
Constants
Python doesn't really have constants, though one still can created them their own way. Names of constants are usually in all uppercase, such as: MY_CONST
.
Functions/Methods
Functions and methods follow the naming scheme of variables, in fact, they're the same.
Classes
Classes follow upper Camel Case, meaning that each word starts with a capital letter, and there are no separations of words, not even underscores. An example of this is: MyClass
.
Last updated