python 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: python code style

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

Example 3: 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

Example 4: class name convention python

# PEP 8 Class names
# Class names should normally use the CapWords convention.

class MyClass:
  def __init__(self):
    # Variable and method names are snake_case
    self.load_time = 25
  def print_value(self, value):
    print(value)