I\'m searching for an elegant way to get data using attribute access on a dict with some nested dicts and lists (i.e. javascript-style object syntax).
For example:>
If your dict is coming from json.loads(), you can turn it into an object instead (rather than a dict) in one line:
json.loads()
import json from collections import namedtuple json.loads(data, object_hook=lambda d: namedtuple('X', d.keys())(*d.values()))
See also How to convert JSON data into a Python object.