Variable number of arguments
massion.francois at gmail.com
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 = _Inputfile
ARGV = _Outputfile
ARGV = _Stopwordsfile
Now I want to allow a variable number of arguments, i.e. 1..n input files or stopwords lists.
In this case ARGV would become [filename1.txt, filename2.txt,...], but I wonder how ARGV 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.
More information about the Python-list