24
Jun, 2010
When I learned Python I became enamored with the idiom of dispatching, which looks something like this:
name = "foo"
function = getattr(object, "prefix_" + name)
function()
In this way we can call object.prefix_foo() without big switch statements or if/else if/else if constructs.
Of course, I usually program in C. While we can’t do exactly the same thing there, the closest analogy is the function … Read More