Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Superclass declaration with instance methods
- class Clothing():
- def wear(self):
- print("I'm wearing this fashionable piece of clothing!")
- def sell(self):
- print("Buy my piece of clothing!")
- # Subclass declaration with instance methods which will inherit the instances in the superclass above. Since the subclass
- # has the same name instance as the superclass, it will automatically override the instances in the parent class when
- # accessed.
- class Socks(Clothing):
- def lose_one(self):
- print("Where did my one go?")
- def wear(self):
- print("Take a look at my sock! They're gorgeous")
- def sell(self):
- print("Buy my socks")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement