On Saturday, November 9, 2013 6:38:25 PM UTC+5:30, John von Horn wrote:
> Another useful tool in the programmer's toolbox

> Select DayofWeek

>       case "mon"

>       ...

> end select


You can typically write this in python as a dictionary

cases = {"mon": do_mon-action, 
         "tue", do_tue_action,
:
:        
}
combined with an 'interpreter'
cases[DayofWeek]()

Some variants:
Need a default?
cases.get(DayofWeek, do_default_action)()

Sometimes nicer to pass some parameters:
cases[DayofWeek](some_relevant_context)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to