fork download
  1. class Foo:
  2. def bar(self):
  3. print "hello bar"
  4.  
  5. def haz(self):
  6. print "hello haz"
  7.  
  8. def nothing(self):
  9. print "None"
  10.  
  11. def __init__(self, choose_me):
  12. {'foo': self.bar,
  13. 'can': self.haz
  14. }.get(choose_me, self.nothing)()
  15.  
  16. if __name__ == '__main__':
  17. Foo('foo')
Success #stdin #stdout 0.09s 8832KB
stdin
Standard input is empty
stdout
hello bar