3 ms·
I was just reading about switch/case in Python yesterday, and came across the following SO post: https://stackoverflow.com/a/46701087/1867039 https://stackover
by wilkystyle 8y ago
I was just reading about switch/case in Python yesterday, and came across the following SO post:
https://stackoverflow.com/a/46701087/1867039 https://stackoverflow.com/a/46701087/1867039
The gist of that answer is that switch/case is not implemented in Python because there is no way to generate an efficient jump table (due to lack of ability to declare constants); given that limitation, any attempts thus far haven't added any benefit over if/elif/else or dictionary dispatch (I am a fan of the latter, personally).
EDIT: Grammar.