python - How to get dictionary objects from a list of tuple objects? -
i have following list of tuple objects :
z = [set([33, u'11:22:33:44:55:ff']), set([12, u'11:22:33:44:54:ce'])]
i want have following list of dictionary objects out of :
d = [{33 : '11:22:33:44:55:ff'}, {12, '11:22:33:44:54:ce'}]
please see -- want use first element of set, dictionary key.
can suggest me code snippet, how perform ?
edit
sorry list of 2 element set objects (and not list of tuple objects).
sets unordered. there no "first" element of set.
you have enforce ordering on them - checking type works:
dict(sorted(x,key=lambda k:isinstance(k,int),reverse=true) x in z) out[33]: {12: u'11:22:33:44:54:ce', 33: u'11:22:33:44:55:ff'}
Comments
Post a Comment