3 ms·
Interesting. Ive seen something similar to this quite often used in Python because it doesn't have Switch statements.
by mgrouchy 13y ago
Interesting. Ive seen something similar to this quite often used in Python because it doesn't have Switch statements.
- gvalkov 13y agoIndeed, 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-...