Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ddonovanHi... The built-in direct equivalent in Python is to use if / elif / else statements to accomplish the same behavior as a switch / case statement in other languages.
so, in Python
if test == a:
doSomething()
elif test == b:
doSomethingElse()
elif test == c:
doAnotherThing()
else:
doDefaultActon()
is the equivalent of
switch(test){
case a:
doSomething();
break;
case b:
doSomethingElse();
break;
case c:
doAnotherThing();
break;
default:
doDefaultAction();
}
in javascript, for example.
There are other, more advanced ways of accomplishing this as well. Some examples here:
http://stackoverflow.com/questions/6...ment-in-python