Makefiles are fantastic tools. They help us automate stuff.
I often run commands like : make epub
or make docs
or make site
etc
I have a simple makefile where I write in shell code. And make
simplifies my life
The commands we write inside makefile are actually shell commands.
Is there a way to write a python file. and run its functions like make.
For example:
Makefile
hi:
echo hi this is makefile
func:
# ... some work
- We can run
make
which would execute stuff under hi, - while running
make func
would execute lines under func. - If there is no Makefile, make would do nothing
Now A python alternative would look like this
'''
hi this is python do file
'''
def func():
# stuff here
- Running
ado
would print the docstring. and running
ado func
would run func.If there is no do.py file in current directory then ado would do nothing