def print_ctypes_struct(struct, name="", ident=0, hexa=False):
    if isinstance(struct, _ctypes._Pointer):
        if ctypes.cast(struct, ctypes.c_void_p).value is None:
            print("{0} -> NULL".format(name))
            return
        return print_ctypes_struct(struct[0], name + "<deref>", hexa=hexa)

    if not hasattr(struct, "_fields_"):
        value = struct
        if hasattr(struct, "value"):
            value = struct.value

        if isinstance(value, basestring):
            value = repr(value)
        if hexa:
            try:
                print("{0} -> {1}".format(name, hex(value)))
                return
            except __HOLE__:
                pass
        print("{0} -> {1}".format(name, value))
        return

    for fname, ftype in struct._fields_:
        value = getattr(struct, fname)
        print_ctypes_struct(value, "{0}.{1}".format(name, fname), hexa=hexa)
dataset/ETHPy150Open hakril/PythonForWindows/windows/utils/pythonutils.py/print_ctypes_struct