My master.py asks for participant name and then run other .py files that use this name:
master.py:
participant = str(input("Participant's name: "))
if __name__ == "__main__":
import os, subprocess
cDir = os.path.dirname(os.path.realpath(__file__))
files = ['antisaccade','change_detection','digit_span']
for f in files:
wDir = cDir+ '/' + f
subprocess.run(["python", f+'.py'], cwd=wDir)
For example, digit_span.py:
sys.path.append(os.path.abspath('../'))
from master import participant
filename = u'data/%s_%s_%s' % participant
So each time files are run, they cyclically call line with input:
participant = str(input("Participant's name: "))
But I need to ask for participant's name only once and then send it to other files.
If I put input() inside if, I get the
ImportError: cannot import name 'participant'
Could someone explain how to solve this, please?