3 ms·
Agree, I do it a lot as a way of selecting functions in a switch statement: handlers = { 'dave' : call_dave(), 'ted' : call_ted(),
by dpritchett 14y ago
Agree, I do it a lot as a way of selecting functions in a switch statement:
handlers = {
'dave' : call_dave(),
'ted' : call_ted(),
'julie' : contact('julie') }
handlers['dave']() # Call dave
handlers['julie']() # Contact julie
[handlers[person]() for person in ['dave', 'julie', 'ted']] # Contact all three