Skip to content

Instantly share code, notes, and snippets.

@JacobCallahan
Created May 14, 2020 15:55
Show Gist options
  • Save JacobCallahan/0cdd4ffaeb4b048f96c88f6ea3a07f77 to your computer and use it in GitHub Desktop.
Save JacobCallahan/0cdd4ffaeb4b048f96c88f6ea3a07f77 to your computer and use it in GitHub Desktop.
from collections import UserDict
class Stub(UserDict):
def __getattr__(self, name):
return self
def __getitem__(self, key):
item = getattr(self, key, self)
try:
item = super().__getitem__(key)
except KeyError:
pass
return item
def __call__(self, *args, **kwargs):
return self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment