Last active
June 20, 2020 18:03
-
-
Save walison17/43a3c655dc58c2a4b6cafd3f79d39879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
class customdict(dict): | |
def __getattr__(self, name): | |
if name not in self: | |
raise AttributeError | |
return self[name] | |
def __setattr__(self, name, value): | |
self[name] = value | |
with open("example.json", "r") as f: | |
data = json.load(f, object_hook=customdict) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment