See below; keys that start with can't be referenced inside an object with dotted notation. If I define missing__() I get "KeyError: '_Stuff__metadata'".
Thanks for this awesome piece of software BTW -- makes my life much better.
import addict
from pprint import pformat
data = {
'foo': 7,
'bar': {
'metadata': {'text': 'this works', 'value': True},
'__metadata': {'text': 'this works', 'value': False}
}
}
dotted = addict.Dict(data)
class Stuff(object):
def __init__(self):
pass
def run(self):
assert pformat(data['bar']) == pformat(dotted.bar), 'text representation does not work'
assert dotted.bar.metadata.text == dotted.bar['__metadata'].text, 'mixed reference broken inside an object'
assert dotted.bar.metadata.text == dotted.bar.__metadata.text, 'dotted reference broken inside an object'
assert dotted.bar.metadata.text == dotted.bar.__metadata.text, 'broken outside an object'
Stuff().run()
See below; keys that start with can't be referenced inside an object with dotted notation. If I define missing__() I get "KeyError: '_Stuff__metadata'".
Thanks for this awesome piece of software BTW -- makes my life much better.