I have a small sample program in python:
import sys
print ("This is the name of the script: "+ sys.argv[0])
print ("Number of arguments: " + str(len(sys.argv)))
print ("The arguments are: " + str(sys.argv))
I run it in Windows CLI:
python args.py -a -b
Output:
This is the name of the script: args.py
Number of arguments: 3
The arguments are: ['args.py', '-a', '-b']
Looks good. Now I call it without specifying "python":
args.py -a -b
Now the output is totally different:
This is the name of the script: C:\args.py
Number of arguments: 1
The arguments are: ['C:\\args.py']
Shouldnt I be getting the same result? Why does it show a different argument count, even though python.exe is executing the program in both cases? How do I correct this?