fork download
  1. class User(object):
  2. MALE = 0
  3. FEMALE = 1
  4. GENDERS = [(MALE, 'Male'), (FEMALE, 'Female')]
  5.  
  6. def __init__(self, gender):
  7. self.gender = gender
  8.  
  9. def greet(self):
  10. return {MALE: 'Hi, boy', FEMALE: 'Hi, girl.'}[self.gender]
  11.  
  12. alex = User(0)
  13. print alex.greet()
Runtime error #stdin #stdout 0.02s 4680KB
stdin
Standard input is empty
stdout
Standard output is empty