Albert-Jan Roskam wrote:

> I have a program that reads and writes files using ctypes. When I want it
> to read AND write (e.g. read a file, select some stuff and write that),
> the library returns a 'read-open' error. I think that the pointer to the
> file handle for read and write point to the same address. 

In C fopen() returns a FILE *, open() returns an int. If your library 
expects a file handle, i. e. an int you can open the file in Python

f = open(filename, "r+b")

and pass f.fileno() to the library.

> To test that
> hypothesis, I wrote the simplified code below. Problem is, that I can't
> make it work, let alone come up with a solution. ;-( How do I tell ctypes
> to use a particular chunck of memory, so read and write buffers do not
> mutually interfere? Maybe the 'offset' parameter of ctypes.byref?

I think you should turn to python-list instead of tutor with problems like 
this.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to