1# mode: run 2# tag: dictiter 3 4def iteritems_unpack(dict the_dict): 5 """ 6 >>> d = {(1,2): (3,4), (5,6): (7,8)} 7 >>> iteritems_unpack(d) 8 [(1, 2, 3, 4), (5, 6, 7, 8)] 9 """ 10 return sorted([ (a,b,c,d) for (a,b), (c,d) in the_dict.iteritems() ]) 11 12def itervalues_unpack(dict the_dict): 13 """ 14 >>> d = {1: (3,4), 2: (7,8)} 15 >>> itervalues_unpack(d) 16 [(3, 4), (7, 8)] 17 """ 18 return [(a,b) for a,b in the_dict.itervalues() ] 19