I have a structure with different datatype fields. I would like to iterate through the structure fields, check the datatype, and set the field with an appropriate value.
Just use the _fields_ list:
_fields_
>>> for f,t in A._fields_: ... a = getattr(A,f) ... print a,a.offset,a.size,t ... 0 4 4 1 5 1