Skip to content

Instantly share code, notes, and snippets.

@unex
Created July 29, 2017 15:04
Show Gist options
  • Save unex/5ef14bc1cc48ed162f2b530fd4078782 to your computer and use it in GitHub Desktop.
Save unex/5ef14bc1cc48ed162f2b530fd4078782 to your computer and use it in GitHub Desktop.
class objdict(dict):
def __getattr__(self, name):
if name in self:
return self[name]
else:
raise AttributeError("No such attribute: " + name)
def __setattr__(self, name, value):
self[name] = value
def __delattr__(self, name):
if name in self:
del self[name]
else:
raise AttributeError("No such attribute: " + name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment