0

I'm running subprocess.run() in a for loop so that each iteration would pass a filename to this function:

myList = ['file1', 'file2']
for item in myList:
    subprocess.run(['foo.py', 'argBar', 'argBaz', item], shell=True, check=True)

but I'm noticing that the item is not being passed to foo.py as an argument.

brainoverflow
  • 691
  • 2
  • 9
  • 22
  • 1
    Do not use `shell=True`. Literally, just take it out, and change nothing else; that's your only problem. – Charles Duffy Dec 16 '21 at 22:26
  • (in general, `shell=True` shouldn't be used _ever_, unless you can't think of a way to make your code work without it; and even in that case, asking here how to make your code work without `shell=True` is typically a better solution than using it). – Charles Duffy Dec 16 '21 at 22:27

0 Answers0