How to pretty-print ctypes composite data types?

Grant Edwards invalid at invalid.invalid
Tue Oct 25 18:50:57 EDT 2011


I'm using ctypes with a library that requires a handful of structure
definitions.  The actual definitions and usage aren't a problem.  When
it comes time to print out the values in a structure or array, there
doesn't seem to be simple/general way to do that.  Am I missing
something?

I presume one can recursively iterate through the fields in a
structure and elements in an array, recursing on any composite types
and printing the values when one finds a type, but I'm surprised
that's not something that's already in the ctypes library somewhere --
the authors certainly seem to have thought of everything else.

-- 
Grant Edwards               grant.b.edwards        Yow! I own seven-eighths of
                                  at               all the artists in downtown
                              gmail.com            Burbank!



More information about the Python-list mailing list