'How to make another .py file recognize an input from another .py file?

So I have two .py files, fileA.py and fileB.py.

fileA.py will make fileB.py run.

But first, fileA.py will have a script to ask a folder directory as an input.

from pathlib import Path
import subprocess
import sys
from tkinter.filedialog import askdirectory

pathcase = askdirectory(title='path to folder')

scripts = [
    'fileB.py'
]

parent = Path(__file__).resolve().parent

for script in scripts:
    script_path = parent / script
    subprocess.call([sys.executable, script_path])

How to make fileB.py run and recognize the "pathcase" input?

fileB.py has:

#!/usr/bin/env pvpython
from paraview.simple import *
from fileA import pathcase
casefoam = OpenFOAMReader(registrationName='case.foam', FileName='{}/case.foam'.format(pathcase))

What is happening right now is that fileA.py runs fileB.py and asks again for an input everytime, making a loop.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source