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

Markus Demleitner msdemlei at tucana.cl.uni-heidelberg.de
Fri May 24 03:53:38 EDT 2002


(Sorry if you've already seen this -- I've posted something to this
effect about a week ago and it seems it didn't make it across our
news server, and at any rate not to google)

The Jython docs state that
open("some.name", "w").write(stuff)
is bad programming practice (and indeed claim that in Jython,
the above construct leaves some.name empty).

Now, I can't really see what should be wrong with doing something
like that.  The temporaray file object generated should have a
refcount of 0 after that line and close the file when being
destroyed, no?  I didn't delve too deep into the docs now,
but IIRC refcount-based garbage collection is sort of a guarateed 
feature of python, isn't it?

Or am I missing something else?

      Markus



More information about the Python-list mailing list