Created
June 8, 2014 00:36
-
-
Save fabiocerqueira/2eeb47175ae7a952457c 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
| import random | |
| class Character(object): | |
| NINJA_NAMES = ['Yumiko Reptile', 'Yori Ninja', 'Yuuko Zero'] | |
| def __init__(self, name, skills): | |
| self.name = name | |
| self.skills = skills | |
| @classmethod | |
| def as_ninja(cls): | |
| name = random.choice(cls.NINJA_NAMES) | |
| skills = ['killer', 'stealth', 'python programmer'] | |
| return cls(name, skills) | |
| def __str__(self): | |
| return "Name: {}\nSkills: {}".format(self.name, ', '.join(self.skills)) | |
| if __name__ == '__main__': | |
| for i in range(2): | |
| c = Character.as_ninja() | |
| print c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment