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

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


[Gary Herron]

> Here's the quote from the Reference Manual: [...]

Yes, I'm well aware of this quote. :-)

> I think we can agree that it must be considered "bad programming practice"
> to depend on features which the manual claims may not exist, past,
> present, or future.

I heartedly agree that it is bad practice not keeping oneself between the
tracks set by specifications.  Without really knowing, I imagine that the
said quote might be a politeness from Guido towards other implementations,
encouraging them, so they could claim being called Python nevertheless.
I wonder if the quote has been there since the beginnings of Python. :-)

>   [...] it is a matter of implementation quality how garbage collection
>   is implemented, as long as no objects are collected that are still
>   reachable.

The current (C-)Python implementation is of high quality on that respect,
and after checking with knowledgeable people, I got that the dependability
of refcounts could be considered as cast in stone, exactly like if it has
been documented as such.  If I did not get this confirmation first, I would
never have started to use things like "open(FILE, 'w').write(CONTENTS)".
Now, I really see it as part of (unwritten) specifications of (C-)Python,
and perfectly legitimate.

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






More information about the Python-list mailing list