[Python-Dev] Proposal for new core module: UserFIle

Guido van Rossum guido at python.org
Thu Dec 11 18:00:27 EST 2003

> > Is there a reason the universal newline mode doesn't cover this case
> > already?
> This module lets you explicitly create a text data file for any
> platform. The universal newline feature of python is for Python modules
> only, and lets you transparently import and exec Python source files
> with the different line ending formats. That is a different thing.

I suggest you go back and read the docs for open() in Python 2.3
again, you are confused with a different feature.

I also note that you change the meaning of readline() to return the
line with the trailing separator stripped, and raise EOFError when you
have reached the end.  That's a big deviation from the standard file
semantics, and shouldn't be done lightly in a subclass (it means that
a TextFile instance is not substitutable for a regular file instance
in most cases).

Reviewing the rest of UserFile, I see several possibly useful
additions (locking, fstat() etc.) and one semantic change that
deserves to be a separate subclass or mix-in (the EINTR behavior).
And nothing that warrants the name "UserFile" (in fact, all the
other UserXXX classes are specifically *not* subclasses of the native
XXX class).

> No, mode r+ lets you create a _single_ file descriptor that is in
> read-write mode. The MergedIO lets you take who file objects (with
> different file descriptors), one readable the other writable, and
> combine them at the method-call level into one read-write object. This
> is useful for pipes, or when you get file objects from libraries.

It looks like you are simply making all write operations go to the
writable object and all the read operations go to the readable object.
That's not a very sophisticated notion of "merging", and I'm not sure
what the point is.  Perhaps some examples of how you use this would

I note that in general your proposals are low on motivation, which is
going to do a lot of damage to your case if you don't fix this soon.
You may be underestimating the level of motivation needed to get
features added to the stdlib -- it's "batteries included" but also (to
some extent) "TOOWTDI".

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list