python variable naming conventions code example

Example 1: python naming conventions

#module names should be all lowercase
import mymodule
#normal variables are lowercase_with_underscores
my_variable = 'value'
#constants are UPPERCASE
CONSTANT = 'never changes'
#classes are UpperCaseCamelCase
class MyClass(self):
    pass

Example 2: camelcase naming convention python

# CamelCase is the way you are meant to name classes:
class ExampleClass(self):
  pass
# Start each word with a capital
# Don't seperate words with underscores

Example 3: pep 8 function

# Pep 8 Style Guide for function definition. Function names are snake case
def function_name():

Example 4: python code style

This python pep sums it up: https://www.python.org/dev/peps/pep-0008/

Example 5: pep8

# pep8 Style Guide for Lists (easier to see indentation imo)
my_list = [
    1, 2, 3,
    4, 5, 6,
]
result = some_function_that_takes_arguments(
    'a', 'b', 'c',
    'd', 'e', 'f',
)

Example 6: python naming script

# Function gets name from user
def get_name():
    print("Hello what is your name?")
    name = input("My name is: ")
    print("Hello ", name)
    return name