grimen / python-attributedict

A dictionary object with attributes support - for Python.
https://pypi.org/project/attributedict
MIT License
18 stars 4 forks source link

Bug with `x.y` style dictionary keys #7

Open gamesbook opened 5 years ago

gamesbook commented 5 years ago

Error trace:

>>> data = AttributeDict({'foo': {'bar': [1, 2, 3]}, 'this.test': 1})
>>> data['this.test']
1
>>> data.this.test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gamesbook/.venvs/attr/local/lib/python2.7/site-packages/attributedict/collections.py", line 226, in __getattr__
    raise AttributeError(error)
AttributeError: 'this'
grimen commented 5 years ago

@gamesbook Thanks for adding this feature request. The library don't have official support for "flat keys" but was listed as a potential feature addition eventually: https://github.com/grimen/python-attributedict/issues/1

I am not sure if I will add support for it or not, as I don't have much usage for it at this time.