[IPython-user] Files left open
Fernando Perez
fperez.net@gmail....
Sat Nov 24 22:21:41 CST 2007
On Oct 23, 2007 4:56 AM, Ken Dere <kdere@gmu.edu> wrote:
> I often have files left open, such as when a piece of code bombs. How
> can I find these files so that I can close them?
Once you have no references left to the file objects (a traceback
would hold such a ref, for example), the Python memory manager will
delete them.
If your script managed to create interactively visible variables with
these files, you can ask for those with 'whos':
In [5]: a=file('release.py')
In [6]: b=file('release.pyc')
In [7]: whos file
Variable Type Data/Info
----------------------------
a file <open file 'release.py', mode 'r' at 0x8663578>
b file <open file 'release.pyc', mode 'r' at 0x84d2f50>
In [8]:
Cheers,
f
More information about the IPython-user
mailing list