Created
March 5, 2018 20:05
-
-
Save t00n/de82a27692e12ba3286bfc510c02ba9e to your computer and use it in GitHub Desktop.
Small module to add the curry() decorator from pymonad on every function of every subsequent import
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
import builtins | |
from inspect import getmembers, isfunction | |
from pymonad import curry | |
old_imp = builtins.__import__ | |
def currify(mod): | |
for name, val in getmembers(mod): | |
if isfunction(val): | |
setattr(mod, name, curry(val)) | |
def custom_import(*args, **kwargs): | |
module = old_imp(*args, **kwargs) | |
currify(module) | |
return module | |
builtins.__import__ = custom_import |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment