GC and resource finalization

Martin v. Löwis loewis at informatik.hu-berlin.de
Mon Apr 29 03:01:03 EDT 2002


"Ian Kjos" <ikjos at email.uophx.edu> writes:

> In the slightly more general case, when (if ever) can the
> interpretter prove that it is safe to close that file? Will the file
> be closed?

In your example, the file will be closed when the cyclic garbage
collection is invoked. This happens at an unspecified time, but can be
triggered with gc.collect().

HTH,
Martin



More information about the Python-list mailing list