Created
July 29, 2015 17:15
-
-
Save jochasinga/f5d913a6013dd4f5a930 to your computer and use it in GitHub Desktop.
Simple example class in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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