-
Notifications
You must be signed in to change notification settings - Fork 0
/
hodor.py
48 lines (31 loc) · 918 Bytes
/
hodor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""hodor"""
# pylint:disable=invalid-name
from __future__ import print_function
def metaclass(cls, mcs):
"py2/py3 compat, hodor"
return mcs("hodor", cls.__bases__, dict(vars(cls)))
class hodor(type):
"""hodor"""
def __repr__(cls):
return "hodor"
def __call__(cls, *args):
return cls
# hodor!
hodor = metaclass(hodor, hodor)
hodor.__class__ = hodor # hodor.
import operator
for op, val in vars(operator).items():
if not op.startswith("__") or isinstance(val, str) or op == "__call__":
continue
setattr(hodor, op, hodor)
setattr(hodor, op.replace("__", "__r", 1), hodor)
for op in ("getattr", "setattr", "delattr"):
setattr(hodor, "__%s__" % op, hodor)
# hodor...
import sys
_ = sys.modules[__name__] # prevent module gc in python 2
sys.modules[__name__] = hodor
__all__ = ("hodor",)
main = hodor
if __name__ == "__main__":
exit(main())