Stream Abstractions in python?

Gerhard Häring gerhard.haering at opus-gmbh.net
Tue Mar 11 14:11:02 CET 2003


Daniel Nielsen <djn at daimi.au.dk> wrote:
> Hi. 
> 
> 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...
> 
> Using google I've found http://www.0x01.com/~thanos/javadata.py ,
> which seems to do what I want, but I'd like to see what other
> alternatives there are out there. 

You might want to take a look at Twisted [1]. It nicely decouples protocol
implementations from the underlying transport, among others. If you're
doing network programming and/or implementing custom protocols it's IMO a
very good framework.

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

Hmm. What about using codecs.EncodedFile for this? [2]

-- Gerhard

[1] http://www.twistedmatrix.com/ -- Argh. Can't connect currently.
[2] http://www.python.org/doc/current/lib/module-codecs.html




More information about the Python-list mailing list