NOT like this question: Calling a python script from command line without typing "python" first
I have a Python script called argparse_test.py. I put it in my system path on my Windows 10 machine so I can call it from any folder by just typing "arparse_test.py" followed by arguments.
The argument works if I call
python argparse_test.py -w
But it does not recognize arguments when I call
argparse_test.py -w
Is there a way to make this work?
Script here:
import argparse
import time
if __name__=='__main__':
# Command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("-w", "--work", action="store_true", help="Make it work")
args = parser.parse_args()
if args.work:
print "It works"
else:
print "It doesn't work"
time.sleep(5)