-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pythonrc
25 lines (23 loc) · 2.33 KB
/
.pythonrc
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
import rlcompleter
import readline
readline.parse_and_bind("tab: complete")
del readline, rlcompleter
from dataclasses import dataclass, asdict, astuple
from datetime import *
from enum import Enum
from functools import *
from itertools import *
from pprint import pprint, pformat
from string import *
import os, sys, random, time, math
rand = random.randrange
_install_dunders = lambda *names: lambda it: ([setattr(it, name, lambda self, *va, _clo_name_=name, **ka: (getattr(it, str(id(self))).append((_clo_name_, va, ka)), self)[1]) for name in names], it)[1]
# TODO: cannot use `__new__`, `__init__` nor `__call__`; also `__repr__`, `__str__` and `__bytes__` basically useless...
@_install_dunders('__del__', '__repr__', '__str__', '__bytes__', '__format__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__hash__', '__bool__', '__getattr__', '__getattribute__', '__setattr__', '__delattr__', '__dir__', '__get__', '__set__', '__delete__', '__slots__', '__init_subclass__', '__set_name__', '__instancecheck__', '__subclasscheck__', '__class_getitem__', '__len__', '__length_hint__', '__getitem__', '__setitem__', '__delitem__', '__missing__', '__iter__', '__reversed__', '__contains__', '__add__', '__sub__', '__mul__', '__matmul__', '__truediv__', '__floordiv__', '__mod__', '__divmod__', '__pow__', '__lshift__', '__rshift__', '__and__', '__xor__', '__or__', '__radd__', '__rsub__', '__rmul__', '__rmatmul__', '__rtruediv__', '__rfloordiv__', '__rmod__', '__rdivmod__', '__rpow__', '__rlshift__', '__rrshift__', '__rand__', '__rxor__', '__ror__', '__iadd__', '__isub__', '__imul__', '__imatmul__', '__itruediv__', '__ifloordiv__', '__imod__', '__ipow__', '__ilshift__', '__irshift__', '__iand__', '__ixor__', '__ior__', '__neg__', '__pos__', '__abs__', '__invert__', '__complex__', '__int__', '__float__', '__index__', '__round__', '__trunc__', '__floor__', '__ceil__', '__enter__', '__exit__', '__match_args__', '__await__', '__aiter__', '__anext__', '__aenter__', '__aexit__', '__buffer__', '__release_buffer__')
class it:
def __init__(self): setattr(it, str(id(self)), [])
def __call__(self, the):
niw = the
for op, va, ka in getattr(it, str(id(self))): niw = getattr(type(niw), op)(niw, *(v(the) if isinstance(v, it) else v for v in va), **dict((k, v(the) if isinstance(v, it) else v) for k,v in ka))
return niw
del _install_dunders