Skip to content

Instantly share code, notes, and snippets.

@0x9900
Last active July 8, 2022 01:26
Show Gist options
  • Save 0x9900/beb25081203476cc959f to your computer and use it in GitHub Desktop.
Save 0x9900/beb25081203476cc959f to your computer and use it in GitHub Desktop.
Dictionary were the elements can be accessed as attributes.
class DictAttr(dict):
def __getattr__(self, key):
if key not in self:
raise AttributeError(key)
return self[key]
def __setattr__(self, key, value):
self[key] = value
def __delattr__(self, key):
del self[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment