Skip to content

Instantly share code, notes, and snippets.

@Echocage
Last active August 29, 2015 14:11
Show Gist options
  • Save Echocage/86bef2dc3fb3b709a988 to your computer and use it in GitHub Desktop.
Save Echocage/86bef2dc3fb3b709a988 to your computer and use it in GitHub Desktop.
class Animal(object):
def __init__(self, name, height, weight, sound):
self.name = name
self.sound = sound
self.weight = weight
self.height = height
def __str__(self):
return "{} is {} cm height {} lbs weight and says {}".format(self.name, self.height, self.weight,
self.sound)
class Dog(Animal):
def __init__(self, name, height, weight, sound, owner):
self.owner = owner
super(Dog, self).__init__(name, height, weight, sound)
def __str__(self):
return "{} is {} cm height {} lbs weight and says {} . His owner is {}".format(self.name, self.height,
self.weight, self.sound,
self.owner)
cat = Animal("piggy", 10, 40, "Meew")
print(cat)
print(type(cat).__name__)
spot = Dog("spot", 112, 160, "lollu", "Imay")
print(spot)
print(type(spot).__name__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment