June 26, 2014

fun with dicts

A Python self invoking dict func. In the example below, whatever `self.mode`, it will call the two named functions if the input to `.get()` is in the dict keys(), else the lambda: None :)
{
    "input": self.input_mode,
    "output": self.output_mode
}.get(self.mode, lambda: None)()