Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Human class
- class human:
- name = 'default'
- age = 0
- height = 0
- affiliation = 'default'
- # Constructor
- def __init__(self, name, age, height, affiliation):
- self.name = name
- self.age = age
- self.height = height
- self.affiliation = affiliation
- # Magic function for string output
- def __str__(self):
- return "<human: name=%s; age=%d; height=%d; affiliation=%s>" \
- % (self.name, self.age, self.height, self.affiliation)
- # Make some humans in a dictionary
- humans = {
- 'steffen': human('steffen', 19, 50, 'noob'),
- 'tony': human('tony', 20, 88, 'noob'),
- 'tomsan': human('tomsan', 19, 87, 'pro')
- }
- # Loop through the humans and print them
- for h in humans:
- print humans[h]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement