title: VERY odd python NameError
body: <p>I am making a python program to pickle some data and then save it to a file. It isn't working.</p>
  
  <pre><code>path="C:/foo/bar"
  def newData():
      import pickle
      data = [
          ["foo"],
          ["bar"],
          ["baz"]
      ]
      file = None
      i = 0
  
      while file==None:
          if not exists(path + str(i)+".data"):
              file = open(path + str(i)+".data", "w+")
          else:
              i+=1
      pickle.dump(data, file)
      close(file)
      return path + str(i)+".data"
  </code></pre>
  
  <p>I get a name error saying that "global name close is not defined":</p>
  
  <pre><code>  File "C:/foo/bar/baz.py", line 26, in newData
      close(file)
  NameError: global name 'close' is not defined
  </code></pre>
  
  <p>If I comment the line with close in it, I get:</p>
  
  <pre><code>  File "C:/foo/bar/baz.py", line 26, in newData
      #close(file)
  NameError: global name 'close' is not defined
  </code></pre>
  
  <p>Is my code wrong (yes)? how?</p>