glom
glom copied to clipboard
When assigning, how to generate a different `missing` structure based on path type?
Starting from an empty dict, I might make assignments like this:
glom.assign({}, "a.0.b", "value", missing=?)
The result I expect is the following:
{ 'a': [ { 'b': 'value' } ] }
although I understand that it could also be interpreted as
{ 'a': { '0': { 'b': 'value' } } }
This means that I want the missing
function to create a list for the missing structure "a", and a dict for the missing structure "a.0".
Unfortunately, missing
isn't called with any arguments that would allow me to return a list or a dict depending on whether the next path part is an int or a string.
Is there some other way to do what I want?
that's a great suggestion, providing arguments to missing