I'm confused how the closed method on a file object can be executed successfully even after the file has been closed, as documented one of the tutorials.
>>> with open('workfile') as f:
...     read_data = f.read()
>>> f.closed
True
I would expect the f.closed command to fail because the with statement should close the file and f should no longer be available. How is the program still able to recognize the f file object after the it is closed?
Also, shouldn't the name f exist only within the with block? How is the program able to recognize the object outside of the with block?
 
    