I have a written a simple class
with an __init__
emulating a switch/case flow:
class Foo(object):
def bar(self):
print "hello bar"
def haz(self):
print "hello haz"
def nothing(self):
print "None"
def __init__(self, choose_me):
{'foo': self.bar(),
'can': self.haz()
}.get(choose_me, self.nothing())
if __name__ == '__main__':
Foo('foo')
Why is everything being selected? - Here is the output it gives me (run it with ideone):
hello bar
hello haz
None