Raw write/read file descriptor

Donn Cave donn at u.washington.edu
Fri Mar 5 17:06:47 EST 2004


In article <050320041320106615%anon at anon.net>, anon <anon at anon.net> 
wrote:

> Is there an interface for read/writing raw bytes to/from a file?

Yes.  In the os (a.k.a. posix) module, open, read and write.
File objects that are really files implement fileno() to
return the file descriptor.

The difference is not so much that the bytes are raw, it's
that there is no intermediate buffer (in process memory space.)
That's often useful with pipes and sockets, but not often with
disk files.

If what you really want is to avoid modifications to the data
stream, but you do want the efficiency and functionality of the
file object's buffered I/O, then you might do better with the
"rb" and "wb" parameters to open.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list