Python: argparse containing a list of variable sizes

In Python, using argparse , I want the input argument to take the number of the variable , for example:

 $ myScript --aParameter file1 file2 file3 ... fileN 

How to do it?

 parser.add_argument( "--aParameter", nargs=????, type=str, help="Provide a list of files to analyze", default=None) 
+6
source share
1 answer

Use kwarg nargs='+' . Thatโ€™s almost all you need.

+11
source

Source: https://habr.com/ru/post/943884/


All Articles