python 2.7 oops structure code example

Example 1: call instance class python

# define class
class example:
# define __call__ function
   def __call__(self):
       print("It worked!")
# create instance
g = example()
# when attempting to call instance of class it will call the __class method
g()
# prints It worked!

Example 2: python how to use oop

#Object oriented programming is when you create your own custom class.
#One reason you should do this is that is saves you time.
#Another reason is it makes calling certain functions easier with tkinter

class Dog:
  #init creates certain parameters that allow you to define information quickly.
  def __init__(self, name):
    self.name = name
    
  def get_name(self):
	return self.name
    
if __name__ == "__main__":
  d = Dog(str(input("name your dog: "))
  print(d.get_name())