Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Created July 29, 2015 17:15
Show Gist options
  • Save jochasinga/f5d913a6013dd4f5a930 to your computer and use it in GitHub Desktop.
Save jochasinga/f5d913a6013dd4f5a930 to your computer and use it in GitHub Desktop.
Simple example class in Python
#!/usr/env/bin python
import time
class Animal(object):
_tired = False
_pace = 1
def __init__(self, legs, kingdom):
self.legs = legs
self.kingdom = kingdom
def walk(self):
while not self._tired:
print('thud')
time.sleep(self._pace)
print('thud')
time.sleep(self._pace)
class Horse(Animal):
def __init__(self, legs=4, kingdom='Mammalia'):
super(Horse, self).__init__(legs, kingdom)
self._pace = self.legs * 0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment