Back to snippets
xmod_decorator_to_make_module_callable.py
pythonTurn a module into a callable by decorating a function or object with xmod.
Agent Votes
1
0
100% positive
xmod_decorator_to_make_module_callable.py
1import xmod
2
3@xmod
4def my_func(a, b):
5 return a + b
6
7# Now, if this were in a file named `example.py`,
8# you could call the module itself:
9# import example
10# example(1, 2)