#!/usr/bin/env python import sys from the_semantic_db_code import * from the_semantic_db_functions import * from the_semantic_db_processor import * C = context_list("play with ordered dictionary") x = ket("a",37) + ket("z",2) + ket("u",9) + ket("v",13) + ket("b") + ket("e",5) y = ket("u",23) + ket("b",17) + ket("fish",21) + ket("cat",37) + ket("a",11) print(x) print(y) # populate a dict version for comparison: dict = {} for elt in x.data: dict[elt.label] = elt.value print(dict) # now try an ordered dict from collections import OrderedDict one_dict = OrderedDict() for elt in x.data: one_dict[elt.label] = elt.value print(one_dict) two_dict = OrderedDict() for elt in y.data: two_dict[elt.label] = elt.value print(two_dict) od = OrderedDict() od.update(one_dict) od.update(two_dict) print(od) intersection_fn(min,x,y)