I am using the subprocess module to execute a command line software with arguments but I am running into a bit of trouble when it comes to feeding it a list of arguments .
Here is what I am doing :
subprocess.call([rv,"[",rv_args[0],rv_args[1],"]",])
This works fine and len(rv_args) == 2 , now I would like to generate this :
if len(rv_args) == 4 :
subprocess.call([rv,"[",rv_args[0],rv_args[1],"]","[",rv_args[2],rv_args[3],"]",])
then
if len(rv_args) == 6 :
return subprocess.call([rv,"[",rv_args[0],rv_args[1],"]","[",rv_args[2],rv_args[3],"]","[",rv_args[4],rv_args[5],"]"])
etc .. etc ..
Of course I don't want to hard code it, but generate it on the fly, what you be the best way ?
cheers,