I wrote a script that makes some calculation and it receives input parameters using argparse.
One of these parameters is a list of file paths.
Looking around I found this other question and I modify my code adding:
import argparse
parser = argparse.ArgumentParser(description='Engine')
parser.add_argument('--outputFile', required=True, help='Output file path [str]')
parser.add_argument('--filesList', nargs='+', required=True, help='List of the input files [list of str]')
args = parser.parse_args()
outputFileName = args.outputFile
inputFilesName = args.filesList
In this way I can pass all the input parameters even the list of the files typing each one separated by a space, like:
--outputFile output.nc
--filesList data/file1.nc data/file2.nc
Now I created the GUI for my script and I call the script using subprocess:
command = [sys.executable,
           'D:/Projects/Calculation/src/modules/Engine.py',
           '--outputFile', self.outputFileName,
           '--filesList', filesPathList]
 p = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=0)
where filesPathList is the list of files path: ['data/file1.nc', 'data/file2.nc']
The problem is if I run the software in this way, what the engine understand is a list of 1 element: ['data/file1.ncdata/file2.nc'], essentially arcparse fuses together all the paths.
Is there any option I can add to add_argument to fix it?
I could change the way to parse the input parameters, but I would like to know if there is a way using argparse.