This might seem like a wierd requirement, but I am looking for a good implementation to do this.
I have a dict like
vals = dict(red='#F00', green='#0F0', blue='#00F')
and a string like
tpl = '{red}:{green}:{blue}'
and the str.formatted output
output = tpl.format(**vals)
All is well till here. However, I now need to do the reverse of this. I have to turn a string like '#F00:#0F0:#00F' into a dict of the values that we previously started with. Of course, I could just split and strip the string and take the values I need, but it will fail in the event the tpl string should change.
Any good ideas on how I can do this (If it can even be done, that is)?