[Python-Dev] Proposal for new core module: UserFIle
Guido van Rossum
guido at python.org
Thu Dec 11 19:57:05 EST 2003
> > > rwio = UserFile.MergedIO(sys.stdin, sys.stdout)
> > That's not a motivation. How does writing rwio.readline() and
> > rw.write() enable your program to do something that wasn't
> > possible by using sys.stdin and sys.stdout directly?
>
> _MY_ programs could do that, but what if you got some third party
> module that wanted a single read/write file object and you wanted to
> use it on stdio?
> It makes APIs more regular and consistent by requiring only one
> read/write object. For example, the library method could be passed a
> single read/write Unix socket, or a read/write TCP socket, or stdio
> object (MergedIO object).
Well, the standard way of wrapping a file object around a socket
pretty much forces you to have separate read and write objects; check
out the makefile() method. :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list