Variable number of arguments

F Massion massion.francois at
Mon Dec 17 13:38:15 EST 2018

My script is used by a web interface which gets some parameters from a form.
The parameters are passed on as arguments like this:

def start(self, _Inputfile ,_Outputfile ,_Stopwordsfile)

As long as the number of arguments is set (i.e. 3), there are no problems running the script.

Currently I have e.g. 
ARGV[0] = _Inputfile
ARGV[1] = _Outputfile
ARGV[2] = _Stopwordsfile

Now I want to allow a variable number of arguments, i.e. 1..n input files or stopwords lists.

In this case ARGV[0] would become [filename1.txt, filename2.txt,...], but I wonder how ARGV[1] would still remain _Outputfile.

I thought of using the argparse module with nargs='+' for a variable number arguments but it seems to work only with Python 2.7 and I have 3.6 running.

Any suggestions?

More information about the Python-list mailing list