Created
May 14, 2020 15:55
-
-
Save JacobCallahan/0cdd4ffaeb4b048f96c88f6ea3a07f77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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