How to use dot notation for dict in python?

This functionality already exists in the standard libraries, so I recommend you just use their class. >>> from types import SimpleNamespace >>> d = {‘key1’: ‘value1’, ‘key2’: ‘value2′} >>> n = SimpleNamespace(**d) >>> print(n) namespace(key1=’value1′, key2=’value2’) >>> n.key2 ‘value2’ Adding, modifying and removing values is achieved with regular attribute access, i.e. you can use statements … Read more

How to use a dot “.” to access members of dictionary?

I’ve always kept this around in a util file. You can use it as a mixin on your own classes too. class dotdict(dict): “””dot.notation access to dictionary attributes””” __getattr__ = dict.get __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__ mydict = {‘val’:’it works’} nested_dict = {‘val’:’nested works too’} mydict = dotdict(mydict) mydict.val # ‘it works’ mydict.nested = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)