Stream Abstractions in python?

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Tue Mar 11 07:41:56 EST 2003


Daniel Nielsen wrote:
> I'm toying around with python... The only reason I see right now to
> continue using java for distributed stuff, is java's
> Data{In,Out}putStream with sockets. Is there an equivalent abstraction
> to TCP streams in Python? I have been looking around www.python.com,
> but couldnt anything...

You should be looking on www.python.ORG instead.
For instance,
http://www.python.org/doc/current/lib/module-socket.html
http://www.python.org/doc/current/lib/module-pickle.html
http://www.python.org/doc/current/lib/bltin-file-objects.html

> Note: I do not require it to be compatible with java's streams, I'd
> just like the convenience of readUTF/writeUTF and friends.

If you want transparent object/data communication, I strongly
suggest you have a look at http://pyro.sourceforge.net

Pyro uses pickling over TCP socket connections to transparently
implement remote method invocation, much like Java RMI.

You could also implement your own protocol if you wish,
where you use the pickle module to marshall your data objects
and use the makefile method of your socket object to create
a file-like stream to write your data to.

Irmen de Jong





More information about the Python-list mailing list