Advertisement
Dammiejoy20

Untitled

Mar 29th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # Superclass declaration with init definition
  2. class Store():
  3.     def __init__(self):
  4.         self.owner = "Joy"
  5.  
  6. # An instance method is invoked
  7.     def exclaim(self):
  8.         return "I'm defined in the superclass"
  9.  
  10. # Declaration of a subclass with no class body which will inherit from the Superclass.
  11. class HardwareStore(Store):
  12.     pass
  13.  
  14. # An instance is instantiated and assigned to a variable
  15. home_depot = HardwareStore()
  16.  
  17. # Access to "owner" attribute on the subclass instance.
  18. print(home_depot.owner)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement