I have a text file which contains configuration values that are intended to be arguments to a C++ executable (to be read in as a vector in C++). I am using a Python script to read in the text file and then call the C++ executable as a subprocess. The reason I'm doing it via Python is because I do not want to modify the C++ executable for unrelated reasons.
Here is my code snippet to achieve this. I was wondering if there's a better way to do this.
call_list = [executable, "--directory", directory, "--filePrefix", file_prefix, "--configList"]
# read config file
config_file = directory + file_prefix + ".txt"
config_list = [line.strip() for line in open(config_file)]
config_list_split = []
for config in config_list:
config_list_split.extend(config.split())
call_list.extend(config_list_split)
subprocess.check_call(call_list)