DEV Community

Serhat Teker
Serhat Teker

Posted on • Originally published at tech.serhatteker.com on

General Naming Conventions for Python

  1. Class names should follow the UpperCaseCamelCase convention,
  2. Functions, variables and attributes should be all lowercase and sparated by an underscore (a.ka. snake_case),
  3. Non-public/protected attributes should begin with a single underscore,
  4. 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!")
Enter fullscreen mode Exit fullscreen mode

For more info: PEP 8 -- Style Guide for Python Code

All done!

Top comments (0)