Closing files

Daniel Dittmar daniel.dittmar at sap.corp
Mon Nov 29 17:01:37 CET 2004


Timo Virkkala wrote:
> Daniel Dittmar wrote:
>> And then there are a lot of people who think that changing all the 
>> readlines one liner would be quite easy should the need of a Jython 
>> port arrive, so why bother about it now?
> 
> The problem with this approach is, when the time for the Jython port 
> arrives, do you remember to do it?

If you can write a unit test now that would fail using Jython, then 
you're going to be reminded quickly.

And perhaps there will be changes to Python
- that make the oppen().readlines () version work in fully garbage 
collected environments; like closing the inner file handle when the end 
of the file is reached
- that suggest a different solution; like declarations on local 
variables that say "call destructor when object goes out of scope"

Then, having more complicated code today doesn't buy you anything.

Daniel



More information about the Python-list mailing list