Python: argparse taking a list of variable size

argparse, input, python

Solution

Use the kwarg `nargs='+'`. That's pretty much all there is to it.

Problem

In Python, using `argparse`, I want an input argument to take a variable number of files, like: ``` $ myScript --aParameter file1 file2 file3 ... fileN ``` How can do it? ``` parser.add_argument( "--aParameter", nargs=????, type=str, help="Provide a list of files to analyze", default=None) ```

Original source