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

Delaney, Timothy tdelaney at avaya.com
Thu May 30 02:19:49 EDT 2002


> From: Donn Cave [mailto:donn at drizzle.com]
> 
> | 1. The documentation explicitly states that you cannot. 
> Anything else is an
> | implementation artifact.
> 
> The real Python _is_ implementation.  We all know that you actually
> can rely on timely finalization, and we can guess why the 
> documentation says what it says.

Then get it documented to say that it can be relied on, now and forever. If
you manage this, documented for all implementations of Python (obviously,
from a particular version number), I will have no qualms with anyone using
this type of construct on that version and later. Of course, it then
introduces backwards-incompatibility.

Until then I must consider any code using this type of construct as broken
and unsafe. Especially since the documentation currently states that this
cannot be relied on, and there is at least one implementation (Jython) where
this is indeed not the case.

I just find it amazing that so many people here are so careful about so many
things, yet seem to have a complete blind spot on this issue. Why don't we
have

	while a = file.readline():
	    pass

while we're at it? After all, it's the same principle - you're trading off
safety for saving a line or two.

Tim Delaney





More information about the Python-list mailing list