Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed as not planned
Description
AttrDict
is used improve the readability of nested data access from JSON files. Compare:
config.servers.setup.interfaces.mgmt.protocol config["servers"]["setup"]["interfaces"]["mgmt"]["protocol"]
Victor's research showed that tooling this is very popular in Python world and the implementationdates back quite far. At first I suggested I suggested extendingSimpleNamespace()
; instead,Guido recommended putting this is the JSON module which is where it would primarily be used:
with open('kepler.json') as f: kepler = json.load(f, object_hook=AttrDict)print(kepler.orbital_period.neptune)
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done
Status
Done