Skip to content

Instantly share code, notes, and snippets.

@afr-dt
Created November 25, 2021 21:47
Show Gist options
  • Save afr-dt/5885468f6c2248ecc05a2205c01fd7c6 to your computer and use it in GitHub Desktop.
Save afr-dt/5885468f6c2248ecc05a2205c01fd7c6 to your computer and use it in GitHub Desktop.
accessing_dict_keys_like_an_attribute
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
config = AttrDict()
# Example
config['name']
config['last_name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment