You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: