3 ms·
switch/case was, and still is, considered unnecessary in Python because it can be expressed just as clearly and concisely using if/elif/else. There was discussi
by zephyrfalcon 8y ago
switch/case was, and still is, considered unnecessary in Python because it can be expressed just as clearly and concisely using if/elif/else. There was discussion about adding it, long ago, but (IIRC) Guido decided against it. It is not obvious what syntax switch/case should have in Python (two levels of indentation?), and its benefits are marginal at best.
Then again, many things that supposedly would "never" make it into the language, have been added over time anyway, including the ternary if. So who knows...
- Quekid5 8y ago> switch/case was, and still is, considered unnecessary in Python because it can be expressed just as clearly and concisely using if/elif/else Ah, but it seems that there's some disagreement about this being unnecessary :). Btw, MultiWayIf is a much more powerful (bad word choice?) than 'switch' because it's more flexible at no additional syntactic cost. FWIW, I mostly just like it because of the extreme syntactic regularity of MWI. (I have no horse in the race. I just use Python occasionally as a scripting language, but I've been moving over to Haskell+Stack for scripts, so... )