Referencing file from method in python
Question: I need some help with this. I am using this method to help me open a file with
a dialog box:

    
    
    from Tkinter import *
    import tkFileDialog
    
    fileOpen = Tk()
    fileOpen.withdraw() #hiding tkinter window
    
    file_path = tkFileDialog.askopenfilename(
    title="Open file", filetypes=[("txt file",".txt"),("All files",".*")])
    
    if file_path != "":
        print "you chose file with path:", file_path
    
    else:
        print "you didn't open anything!"
    
    print file_path
    

It works fine, and the file is opened in Python, but I don't know how to make
further commands on that file, for example if I wanted to read it or write on
it.  
I have tried referencing it as fileOpen, but that doesn't seem to work, and I
have no idea what the variable would be instead.


Answer: The file is not opened at all. To open it, call `open(file_path)`. That gives
you an object your can `read` from or `write` to. Please read the Python
tutorial's [section on file
I/O](http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-
files).

