I have tried this a few ways and while I cannot share specifics of my project I can boil it down to its essence.
I have something like below
import argparse,sys
parser = argparse.ArgumentParser()
parser.add_argument('password', help='The password')
parser.add_argument('--optionalArg', help='Just an optional arg')
args=parser.parse_args()
print(sys.argv[1])
When running this from a Windows 10 PC with Python 3.6.x installed I get output like below:
test.py test --optionalArg myArg
test --optionalArg myArg
I have even tried with Argparse examples from Python directly and get similar behavior.
Now, coincidentally on another machine, also running Windows 10, and Python 3.6.x it works. Now they are two minor versions off.
I also saw another question on SO (Though having issues finding it) suggesting that in HKLR/Applications/python to ensure there is a "%*" which made the first argument show up at all on the machine where it does not work. This stated I am noticing this entry does not exist at all on the machine it is working on.
I understand this is likely a registry problem or something else regarding the installation. I am further investigating to see if I can pinpoint the problem.
I will update here with any additional questions.
EDIT:
I have trimmed example code to three lines only:
import sys
print(sys.argv[1])
print(sys.argv[:1])
still outputs the following:
>argtest.py 1 2 3
1 2 3
['1 2 3']
on the machine with the issue.