def pmt_to_dict(p): d = dict() items = pmt.dict_items(p) for i in range(pmt.length(items)): pair = pmt.nth(i, items) k = pmt.car(pair) v = pmt.cdr(pair) d[pmt_to_python(k)] = pmt_to_python(v) return d