0

My code looks like this:

File A:

import os
inputA = input("Input: ")
os.system('InputTest.py')

File B:

inputB = input("Input: ")  # <-- I want this to automatically get filled in with inputA
print(inputB)

I want to have the input variable from file A fill the input request in file B (in the terminal).

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

2 Answers2

0

Not a direct answer, but why don't you use sys.argv? i.e.:

script A

import os, sys

inputA = input("Input: ")
os.system('python /full/path/to/InputTest.py ' + inputA )

script B (InputTest.py)

import sys

if len(sys.argv) > 1:
    print(sys.argv[1])
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
-1

i'm not sure of what you want to do,but,if u need to connect 2 scripts,maybe you can use socket lib,and make client-server connection. Or,to thing a "different" solution,you can make a text file,where one script write and another script read. Another solution can be,when you get input,you can open other python file and send input with pyautogui lib.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Aegis
  • 21
  • 4