title: How to get a string from the tkinter filedialog in Python 3?
body: <p>I'm attempting to use the tkinter <code>filedialog</code> to get the user's choice of a file in my Python 3.4 program.</p>
  
  <p>Previously, I was trying to use the Gtk FileChooserDialog, but I keep running into wall after wall getting it to work (<a href="https://stackoverflow.com/questions/29980352/how-to-hide-a-gtk-filechooserdialog-in-python-3-4">here's my question about that</a>.) So, I (<em>attempted to</em>) switched over to tkinter and use the filedialog.</p>
  
  <p>Here's the code I'm using for the GUI:</p>
  
  <pre><code>import tkinter
  from tkinter import filedialog
  
  root = tkinter.Tk()
  root.withdraw()
  
  path = filedialog.askopenfile()
  
  print(type(path)) # &lt;- Not actually in the code, but I've included it to show the type
  </code></pre>
  
  <p>It works perfectly, except for the fact that it returns an <code>&lt;class '_io.TextIOWrapper'&gt;</code> object instead of a string, like I expected/need it to.</p>
  
  <p>Calling <code>str()</code> on that doesn't work, and neither does using the <code>io</code> module function <code>getvalue()</code>.</p>
  
  <p>Does anyone know how I could get the chosen file path as a string from the <code>filedialog.askopenfile()</code> function?</p>