3 ms·
Indeed, it's quite idiomatic. I would have still preferred if there was a switch/case construct that would generate a dispatch table for us (in fact, this was p
by gvalkov 13y ago
Indeed, it's quite idiomatic. I would have still preferred if there was a switch/case construct that would generate a dispatch table for us (in fact, this was proposed and rejected in pep 3103[1]). A case statement would have been a nice, little addition to the expressiveness of Python, but it's not that big of a deal.
Here's another dispatch table technique that I really like[2].
[1]: www.python.org/dev/peps/pep-3103/
[2]: http://code.activestate.com/recipes/577864-fast-and-elegant-switchcase-like-dispatch/ http://code.activestate.com/recipes/577864-fast-and-elegant-...