-1

I am calling a function, func_1.py, from my main one (func.py) using

import os
cmd = 'python func_1.py [x y t]'
os.system(cmd)

x, y and t are defined before in func.py.

func_1.py starts with def the_reader(index, x, y, peak_number):. When I run func.py I don't have problem compiling, but func_1.py doesn't do what expected. Am I doing something wrong?

albus_c
  • 6,292
  • 14
  • 36
  • 77

1 Answers1

1

You can only pass in strings into the system command. You are passing the command line parameter "[x y t]". You have to extract the variables before the command. I believe that your statement on the command line == python func_1.py [x y t] # No values just "[x y t]"

import os
cmd = "python func_1.py " + str(x) +" "+ str(y) +" "+ str(t)
os.system(cmd)
justengel
  • 6,132
  • 4
  • 26
  • 42