How to write partial of a buffer which was returned from a C function to a file?

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Apr 14 20:20:02 EDT 2018


Jach Fong wrote:
>  >>> pvoid = ctypes.c_void_p(ctypes.addressof(buf0))
>  >>> pvoid.contents
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'c_void_p' object has no attribute 'contents'

I think the 'contents' attribute only applies to pointers that are
pointing at part of another Python object. Your c_void_p instance
is not that kind of pointer.

I must say the ctypes documentation is rather confusing when it
comes to these kinds of details. It doesn't help that the "Pointers
and Arrays" section is marked as "Not yet written". Does anyone
have any plans to finish it?

-- 
Greg



More information about the Python-list mailing list