Created
May 8, 2019 14:24
-
-
Save pseud0n/ef6aba28d950c4e95637d343a3386408 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
class Meta(type): | |
def __getattr__(cls, key): | |
return globals()[key] | |
def __setattr__(cls, key, value): | |
globals()[key] = value | |
def hasattr_(cls, key, original = hasattr): | |
if "hasattr" in cls.__dict__.keys(): #No recursion today | |
return key in globals().keys() | |
return original(cls, key) | |
__builtins__.hasattr = hasattr_ | |
class main(metaclass = Meta): | |
pass | |
if __name__ == "__main__": | |
main.foo = 10 | |
print(foo) | |
print(hasattr(main, "bar")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment