def pmt_to_tuple(p): elems = list() for i in range(pmt.length(p)): elem = pmt.tuple_ref(p, i) elems.append(pmt_to_python(elem)) return tuple(elems)