Skip to content

Instantly share code, notes, and snippets.

@calthoff
Created March 2, 2017 17:50
Show Gist options
  • Save calthoff/8ad5ae800f2ed4d17ea906861ce9a599 to your computer and use it in GitHub Desktop.
Save calthoff/8ad5ae800f2ed4d17ea906861ce9a599 to your computer and use it in GitHub Desktop.
# This program is chapter 14 challenge one:
class Shape():
def __init__(self, shape):
self.shape = shape
def what_am_i(self):
print("I am a {}".format(self.shape))
class Square(Shape):
def what_am_i(self):
super(Square, self).what_am_i() # super is for multi-inheritance
class Rectangle(Shape):
def what_am_i(self):
super(Rectangle, self).what_am_i()
# Create some objects:
square = Square("square")
rectangle = Rectangle("rectangle")
square.what_am_i()
rectangle.what_am_i()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment