python - List of arguments with argparse -


I am trying to pass a list of arguments with argparse, but the only way I have found Repeat the option for each argument I want to pass:

What I currently use:

  main.py-arg arg1 -a arg2  

And I want to:

  main.py -t arg1 arg2 ...  

Here my code Is:

  Parser.add_argument ("- t", action = 'append', destroy = 'table', default T = [], help = "")  

Use:

Logic pacer objects are usually associated with the same action-line logic. nargs keyword logic associates a different number of command line arguments with a single action. For example, if nargs is set to '+'

such as '*' , all the command line Arguments are collected in a list Additionally, at least one command line argument was not present, an error message would be generated.

Then, your code will look like this

  Parser.add_argument ('-t', dest = 'table', help = '', nargs = ' + ')  

Automatically assemble in -t logic list this way (you do not have to specify explicitly ).


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -