Step 1: Right click on a python script and use open-with to open with your python.exe
Step 2: Change registry so that running your python script from command line will cause python.exe to read individual arguments, and not to combine all arguments into a single string.
Note that due to Windows limits, only the first 8 arguments are available individually. Downside is os.argv will contains empty strings appended when less than 8 arguments. The alternative is to use %* which would join all arguments with spaces but make it available as sys.argv1
The fix is to add a code:
while sys.argv[-1] == '':
del sys.argv[-1]
Use Regedit, or save below to a .reg file, edit the path, then run it.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
@=""C:\Users\andrewm\anaconda3\python.exe" "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "
[HKEY_CLASSES_ROOT\py_auto_file\shell\open\command]
@=""C:\Users\andrewm\anaconda3\python.exe" "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "
regedit