Created
July 19, 2015 02:55
-
-
Save offby1/52ca7be4b78a1a91f786 to your computer and use it in GitHub Desktop.
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
| class Cat(object): | |
| def __init__(self): | |
| self.tummy = [] | |
| def eat(self, thing): | |
| self.tummy.append(thing) | |
| def hairball(self): | |
| print("I puked up a {}".format(self.tummy.pop())) | |
| snowball = Cat() | |
| snowball.eat('fish') | |
| snowball.eat('shoelace') | |
| snowball.hairball() | |
| snowball.hairball() | |
| # I puked up a shoelace | |
| # I puked up a fish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment