General Naming Conventions for Python
- Class names should follow the
UpperCaseCamelCase
convention, - Functions, variables and attributes should be all lowercase and sparated by an underscore (a.ka.
snake_case
), - Non-public/protected attributes should begin with a single underscore,
- Use double underscore for private attributes.
class MyPythonClass:
def regular_attribute(self):
print("Hello Python!")
def _protected_attribute(self):
print("Hello Python!")
def __private_attribute(self):
print("Hello Python!")
For more info: PEP 8 – Style Guide for Python Code
All done!
Subscribe
Read Related