[Tutor] How to open the closed file again?

Andre Engels andreengels at gmail.com
Tue Jan 5 14:55:28 CET 2010


On Tue, Jan 5, 2010 at 1:46 PM, 朱淳 <zhuchunml at gmail.com> wrote:
> I've token a dictionary to save filenames, and write it into "constant.py".
> And I think it's a good method to create a class as Andre wrote.  Thank you
> all!
> By the way, if I close a open file object, will the closed file object still
> occupy the memory ? As I saw in a list, this kind of unusable file object
> wasn't cleaned by GC. What will happen if there's no list?

In general, when an object is not referred any more in Python code, it
will be garbage collected (and thus the memory it occupies will become
free); however, this is not robust nor fully consistent over
implementation, and it is therefore unadvisable to write code that
relies too heavily on this.


-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list