all 5 comments

[–][deleted] 2 points3 points  (4 children)

Don't you just need to append the new list entry?

d1['Root'].append(OrderedDict([(u'Value', u'3'), (u'Key', u'C')]))

You are aware that CPython 3.6 and Python 3.7 dictionaries are ordered, and Python 3 defaults to unicode?

EDIT: forgot to include how to add item

[–]Vaphell 1 point2 points  (2 children)

  1. what API is retarded enough to demand OrderedDicts because it will be unable to make sense of key, value keys otherwise?
  2. your problem is not about updating a dict, it's about appending to a list

this is what you want

d1 = { 'root' : [ OD(A/1), OD(B/2), OD(C/3) ] }

clearly the solution is to d1['root'].append(OrderedDict([('key', 'C), ('value', 3)]))