3 ms·
It is kinda black magic, and I think it's not something people would expect. You can import other things just fine though: import sys def wat(): print
by notpushkin 2y ago
It is kinda black magic, and I think it's not something people would expect. You can import other things just fine though:
import sys
def wat(): print("wat")
def bar(): print("bar")
wat.wat = wat
wat.bar = bar
sys.modules[__name__] = wat
...
>>> import wat
>>> wat()
wat
>>> from wat import bar
>>> bar()
bar
Edit: I think a better way would be to instead add __call__ to the current module somehow though.