Let’s say you have a python file and you want to run some functions from it in the command line. You have a folder called:
In that file you have a function called beep:
How do you call it from the command line without adding a main block? Maybe you run it with the interpreter:
Other than that, without changing your code, adding argument parsing and so on, how do you run them?
Specially if you want to pass arguments to these functions it quickly becomes dirty to use
python -c for that.
Now you can just do
pip install runp and:
It also works with function arguments, optional arguments, you can check which functions a file contains, get information on what each of them do (with docstrings) and so on.
Check it out on github at the runp repo.