Skip to content

Instantly share code, notes, and snippets.

@joelburton
Created July 31, 2020 18:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelburton/d71e8bc5fac8c912fdf2bcf488003824 to your computer and use it in GitHub Desktop.
Save joelburton/d71e8bc5fac8c912fdf2bcf488003824 to your computer and use it in GitHub Desktop.
For JS programmers who like to use obj.key = val
class POJO(dict):
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, val):
try:
super().__getattr__(self, attr)
super().__setattr__(self, attr, val)
except AttributeError:
self[attr] = val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment