title: Error while sending a filename as a parameter to a function module in python. How to solve?
body: <pre><code>#This code does the checking of the function input.
  
  import re
  import sys
  
  
  def pyexam(file_name):
      fp = open(file_name) 
      testCaseInput = open('input.txt','r')
      testCaseOutput = open('output.txt','r')
  
      eval(compile(fp.read(),'prob.txt','exec'))
      if add(int(testCaseInput.read())) == int(testCaseOutput.read()):
          print "yes"
      else:
          print "no"
  
  file_name ='prob.txt'
  pyexam(file_name)
  </code></pre>
  
  <p>The file prob.txt has an add module.</p>
  
  <p>This works without enclosing it in a function. Also, it works when I send the file name as the parameter. So, its very confusing as to why it is not working when I send the filename as a parameter to the function module. The error I get is this:</p>
  
  <pre><code>File "exam.py", line 13, in pyexam
      if add(int(testCaseInput.read())) == int(testCaseOutput.read()):
  NameError: global name 'add' is not defined
  </code></pre>