import operator ops = { "+": operator.add, "-": operator.sub } # etc. print(ops["+"](1,1)) # prints 2