Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Superclass declaration with init definition
- class Store():
- def __init__(self):
- self.owner = "Joy"
- # An instance method is invoked
- def exclaim(self):
- return "I'm defined in the superclass"
- # Declaration of a subclass with no class body which will inherit from the Superclass.
- class HardwareStore(Store):
- pass
- # An instance is instantiated and assigned to a variable
- home_depot = HardwareStore()
- # Access to "owner" attribute on the subclass instance.
- print(home_depot.owner)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement