0

In terminal I would type something close to:

python main.py --something-something parameter1 --something- parameter2

Because that's how the program works. I need to run main.py in another python script but also need to have "--something-something parameter1 --something- parameter2" as part of it.

I have already looked What is the best way to call a script from another script? [closed] and some others but they did not answer to my problem.

Is this possible with importing os? Lets say the parameter 2 is ID and its value is integer 1234 and parameter 1 dog is "dachshund".

I tried something close to:

dog = "dachshund"
ID = 1234
os.system("python main.py --something-something {dog} --something- {ID}")

But obviously it did not work and there must the right way to do this and there may even be better ways than using os.system(). Thanks in advance!

1 Answers1

0

Create the string you will use first

pythonCall = 'python main.py --something-something {} --something- {}'.format(dog, ID)
os.system(pythonCall)