title: Using a dictionary as a switch statement in Python
body: <p>I'm trying to make a simple calculator in Python, using a dictionary. Here's my code:</p>
  
  <pre><code>def default():
      print "Incorrect input!"
  
  def add(a, b):
      print a+b
  
  def sub(a, b):
      print a-b
  
  def mult(a, b):
      print a*b
  
  def div(a, b):
      print a/b
  
  line = raw_input("Input: ")
  parts = line.split(" ")
  part1 = float(parts[0])
  op = parts[1];
  part3 = float(parts[2])
  
  dict = {
      '+': add(part1, part3),
      '-': sub(part1, part3),
      '*': mult(part1, part3),
      '/': div(part1, part3)
      }
  
  try:
      dict[op]
  except KeyError:
      default()
  </code></pre>
  
  <p>but all the functions are activated. What's the problem?</p>