Why no open(f, "w").write()?

François Pinard pinard at iro.umontreal.ca
Wed May 29 20:59:39 EDT 2002


[Sean 'Shaleh' Perry]

> depending on implementation is almost never a good idea.  Sure CPython
> behaves this way now, but it may not next month or next year.

I've been told that the behaviour is there to stay.  We may depend on it.

> As a matter of habit in any long running program I am always close() what
> needs to be closed and in other way attempt to help the garbage collector.

This is surely good to explicitly `close()' when one is done with a file,
but needs to keep a reference on this file for other reasons.  The nicest
is not keeping a reference to the file, whenever it can be avoided easily.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard






More information about the Python-list mailing list