I would like to write to a dictionary with a 'list-path'. I have:
container = {}
path = ['foo', 'bar']
data = [1, 2, 3]
And would like to get
container = {
'foo' : {
'bar' : [1, 2, 3]
}
}
To read, I am very enthusiastic about this answer, which says that to read:
data = functools.reduce(operator.getitem, path, container)
But now I'm not managing to get the opposite right...
(I guess one could use recursion, but a one-line solution seems near!)