I have written some python code that takes command line options. I'd like to automate running every combination, instead of having to manually type all combinations.
At the moment I have a perl script that looks something like this (although with more options an therefore more nested foreach loops):
use Cwd;
$curdir=getcwd;
@opt1 = ("", "-s");
@opt2 = ("","-w \'binary\'", "-w \'tf\'", "-w \'tfidf\'") #There are arguments but there is a finite amount of them.
foreach $s (@opt1) {
foreach $t (@opt2) {
$cmd="python myCode.py $s $t";
system($cmd);
}
}
This results in the following being run python myCode.py -t 'binary'
,python myCode.py -t 'tf'
,python myCode.py -t 'tfidf'
,python myCode.py -s -t 'binary'
,python myCode.py -s -t 'tf'
,python myCode.py -s -t 'tfidf'
.
This seems like a horrible way to do it (considering I actually have many more options), is there a proper or better way? I'm open to using python to automate this, I have used perl initially as I have a perl script goes onto to call other programs.