Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Human class
- class human:
- age = 0
- height = 0
- affiliation = 'noob'
- # Constructor
- def __init__(self, age, height, affiliation):
- self.age = age
- self.height = height
- self.affiliation = affiliation
- # Magic function for string output
- def __str__(self):
- return "<human: age=%d; height=%d; affiliation=%s>" \
- % (self.age, self.height, self.affiliation)
- # Make some humans in a dictionary
- humans = {
- 'steffen': human(19, 50, 'noob'),
- 'tony': human(20, 88, 'noob'),
- 'tomsan': human(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