use fileinput to read a specific line

Fredrik Lundh fredrik at pythonware.com
Tue Jan 8 08:44:52 EST 2008


Steven D'Aprano wrote:

> Python guarantees[1] that files will be closed, but doesn't specify when 
> they will be closed. I understand that Jython doesn't automatically close 
> files until the program terminates, so even if you could rely on the ref 
> counter to close the files in CPython, it won't be safe to do so in 
> Jython.

 From what I can tell, Java's GC automatically closes file streams, so 
Jython will behave pretty much like CPython in most cases.  I sure 
haven't been able to make Jython run out by file handles by opening tons 
of files and discarding the file objects without closing them.  Has anyone?

</F>




More information about the Python-list mailing list