title: Python file() function
body: <p>I've been adapting an old piece of code to be Python 3 compliant and I came across this individual script</p>
  
  <pre class="lang-py prettyprint-override"><code>"""Utility functions for processing images for delivery to Tesseract"""
  
  import os
  
  
  def image_to_scratch(im, scratch_image_name):
      """Saves image in memory to scratch file.  .bmp format will be read 
          correctly by Tesseract"""
      im.save(scratch_image_name, dpi=(200, 200))
  
  
  def retrieve_text(scratch_text_name_root):
      inf = file(scratch_text_name_root + '.txt')
      text = inf.read()
      inf.close()
      return text
  
  
  def perform_cleanup(scratch_image_name, scratch_text_name_root):
      """Clean up temporary files from disk"""
      for name in (scratch_image_name, scratch_text_name_root + '.txt',
                   "tesseract.log"):
          try:
              os.remove(name)
          except OSError:
              pass
  </code></pre>
  
  <p>On the second function, <code>retrieve_text</code> the first line fails with:</p>
  
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    File ".\anpr.py", line 15, in &lt;module&gt;
      text = image_to_string(Img)
    File "C:\Users\berna\Documents\GitHub\Python-ANPR\pytesser.py", line 35, in image_to_string
      text = util.retrieve_text(scratch_text_name_root)
    File "C:\Users\berna\Documents\GitHub\Python-ANPR\util.py", line 10, in retrieve_text
      inf = file(scratch_text_name_root + '.txt')
  NameError: name 'file' is not defined
  </code></pre>
  
  <p>Is this a deprecated function or another problem alltogether? Should I be replacing <code>file()</code> with something like <a href="https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files" rel="noreferrer"><code>open()</code></a>?</p>