New user's initial thoughts / criticisms of Python
rusi
rustompmody at gmail.com
Sat Nov 9 10:38:49 EST 2013
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)
More information about the Python-list
mailing list