How to run python script with multiple arguments in bash for loop?

434 views Asked by At

I have a python script that I'd like to run in bash for loop in parallel. Python script takes multiple arguments as inputs via sys.argv[x]. For example, I'd like to run in bash for loop these lines:

python py_script.py a b c &
python py_script.py d e f &
python py_script.py g h i

How could I accomplish this? Thank you in advance.

1

There are 1 answers

2
Python_user_3 On

What do you want achieve when running this program? If you want those files to open/run i can show you a method but otherwise i don't know. Sorry :(

Heres how to run a .py file:

from subprocess import call # Importing the call function

call(["python", "file.py"]) # Calling the file to open