Skip to content

Python Naming Conventions

Links: 108 Python Index


Naming Conventions

  • Camel Case: myVariableName
    • Used in Java, JavaScript and other programming languages
    • Not used in Python.
  • Snake Case: my_variable_name or my_function_name
    • Used in python to name variables and functions.
  • Pascal Case: MyClassName
    • Also known as Capital Camel Case
    • Used to name classes in python.
  • Kebab Case: some-package-name
    • Also known as Lisp case or caterpillar case
    • Generally you will see this kind of naming convention while installing packages using pip.
      • pip install opencv-python or pip install scikit-learn
    • We install packages in Kebab case but import them using snake case
      • attachments/Pasted image 20230121130414.jpg
  • Upper Snake Case: SOME_CONSTANT_VARIABLE
    • Used to define constants in python.
  • Flat Case: myvariablename
    • Leads to NOT so readable names.
  • Cobol Case: MY-VARIABLE-NAME

Last updated: 2023-01-21