Skip to content

Instantly share code, notes, and snippets.

@fabiocerqueira
Created June 8, 2014 00:36
Show Gist options
  • Select an option

  • Save fabiocerqueira/2eeb47175ae7a952457c to your computer and use it in GitHub Desktop.

Select an option

Save fabiocerqueira/2eeb47175ae7a952457c to your computer and use it in GitHub Desktop.
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