Happy for it not to have fall-through.
I guess my_dict.get(myvar, default)() would be simple enough.
That said, I never really had a problem not having switch either.
Happy for it not to have fall-through.
I guess my_dict.get(myvar, default)() would be simple enough.
That said, I never really had a problem not having switch either.
It's very useful in times for us who use switch regularly. I have no skin in the python game though so just curious from an outside dev haha
Perhaps some languages conventions are different, but for example Douglas Crockford on JS:
> "switch Statement
A switch statement should be avoided, but when used should have this form:
switch (expression) {
case expression:
statements
default:
statements
}
Each case is aligned with the switch. This avoids over-indentation. A case label is not a statement, and should not be indented like one.Each group of statements (except the default) should end with break, return, or throw. Do not fall through."
My problem with languages trying to too strictly control stuff like this, is that this is stuff that should be handled in your code review process. Sometimes when working with old code, it's not really worth the time spent refactoring a whole switch when you need to make a small fix, vs adding a single line.