Answers for "python access dictionary by dot notation"

1

python dict dot notation

>>> from types import SimpleNamespace
>>> d = {'key1': 'value1', 'key2': 'value2'}
>>> n = SimpleNamespace(**d)
>>> print(n)
namespace(key1='value1', key2='value2')
>>> n.key2
'value2'
Posted by: Guest on October-13-2020
0

accessing python dictionary values with dot

class dotdict(dict):
    """dot.notation access to dictionary attributes"""
    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__
Posted by: Guest on May-28-2021

Code answers related to "python access dictionary by dot notation"

Python Answers by Framework

Browse Popular Code Answers by Language