title: How to get python to open an outside file?
body: <p>I am writing a program for class that opens a file, counts the words, returns the number of words, and closes. I understand how to do everything excpet get the file to open and display the text This is what I have so far:</p>
  
  <pre><code>    fname = open("C:\Python32\getty.txt") 
      file = open(fname, 'r')
      data = file.read()
      print(data)
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>    TypeError: invalid file: &lt;_io.TextIOWrapper name='C:\\Python32\\getty.txt' mode='r'
      encoding='cp1252'&gt;
  </code></pre>
  
  <p>The file is saved in the correct place and I have checked spelling, etc.  I am using pycharm to work on this and the file that I am trying to open is in notepad.</p>