Advertisement
gauravssnl

super & object keyword.py

Oct 31st, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # super and object keyword.py
  2. """ shows use of super and object keyword in python to initialise Parent class method """
  3. # Parent class
  4. class Person(object):
  5.     def __init__(self,name):
  6.         self.name = name
  7.  
  8. # Child class
  9. class Employee(Person):
  10.     def __init__(self,name,salary):
  11.         # call Parent class method
  12.         super(Employee,self).__init__(name)
  13.         self.salary = salary
  14.  
  15. gaurav = Employee("Gaurav",500)
  16. print gaurav.name
  17. print gaurav.salary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement