print all python Structure field values
ctypes, python, structure
Solution
This is basic function that print all fields and sub-structures.
def f(obj):
for k,v in obj.__dict__.items():
print k ,v
if hasattr(v,'__dict__'):
f(v)
Of course, you can add conditions to the function, to filter out unneeded data etc.
Problem
I've trying to write a small program which could read .h file, then generate ctypes.Structure classes from struct in .h file. Then i'm reading binary file into the Structures. And then i need to print out all of the Structure field values (including arrays and subStructures). How can i do it?