Last active
October 11, 2019 15:05
-
-
Save johnberroa/a4eac050e759ba868ba2f9f609bed793 to your computer and use it in GitHub Desktop.
Replace any class with this to essentially disable all references to it in code. Use this instead of many try/excepts or ifs.
This file contains 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
class Disabled: | |
"""Class that absorbs all attribute and method calls on it""" | |
def __init__(self, *args, **kwargs): | |
pass | |
def __getattr__(self, item): | |
return self | |
def __call__(self, *args, **kwargs): | |
return self | |
def __getitem__(self, item): | |
return self | |
def __enter__(self): | |
return self | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
return self |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment