Since I started developing with python I never found myself in the need of such statement. As I remember I never asked where is the switch statement in this language. I think I never asked that because of the dictionary data type in python that you can use to do the same thing as a switch statement will do. I was surprised that there are many PEPs about adding the switch statement to python.

In other languages the switch statement looks like this:

switch (var)
{
case value1: do_some_stuff1();
case value2: do_some_stuff2();
...
case valueN: do_some_stuffN();
default: do_default_stuff();
}

in python one can do the same thing with the help of a dictionary like this:


values = {
value1: do_some_stuff1,
value2: do_some_stuff2,
...
valueN: do_some_stuffN,
}

values.get(var, do_default_stuff)()

Here is link to a post where there are many comments that try to come up with an alternative:
http://simonwillison.net/2004/May/7/switch/

Why should python have a switch statement when there is a more powerful way to do the same with a dict data type ?
Should Python also have a GOTO ?