The question as stated contains a bit of a misunderstanding, or I have a big one.
*keyword and **keyword are for passing parameters/stuff to classes/functions/methods INSIDE the python code.
argparse is used to pass arguments/options into the python program from outside/the commandline. So you're not going to get a 1 for 1 replication of it. However argparse is pretty configurable, and depending on how you want to do it you can come close.
If you only want to pass one name, then:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("name")
args = parser.parse_args()
print args
will let you:
$ ./pytest.py dave
Namespace(name='dave')
If you want to set name so you can send other stuff as well:
parser.add_argument("-name")
Will let you:
./pytest.py -name dave
Namespace(name='dave')
but notice:
./pytest.py -name dave -name steve
Namespace(name='steve')
However:
parser.add_argument("--name")
will let/require:
./pytest.py --name dave
Namespace(name='dave')
./pytest.py --name=dave
Namespace(name='dave')
and if you:
parser.add_argument("--name", nargs="+")
./pytest.py --name dave steve murphy
Namespace(name=['dave', 'steve', 'murphy'])
But:
./pytest.py --name=dave --name=steve --name=murphy
Namespace(name= ['murphy'])
(note that that last one is a list with only murphy in it.)
So what you could do is:
parser.add_argument("--name")
parser.add_argument("--email")
parser.add_argument("--hair-color")
./pytest.py --name fred --hair-color murphy --email example@example.com
Namespace(email='example@example.com', hair_color='murphy', name='fred')