View Single Post
  #3  
Old 12-06-2017, 06:48 AM
Vishav Vishav is offline
Member
 
Join Date: Jun 2017
Posts: 57
Same error is coming with code suggested by you.

I will explain it
I have one file called Parent in which i created file experiment_data having write mode using code.

os.chdir(r'D:\PhD\Study-I_Part_I\My_Programs\DFI\Participant_Data')
experiment_data = open(str(id) + '_experiment_data.txt','w')
data = " Participant ID: %s\tParticipant Name: %s\tAge: %s\tGender: %s\n\n" % (id,Name,Age,gender)
experiment_data.write(data)

After that i made a child code to which i passed id variable value to child using code
id=id
myVars = {'id':id}
exec(open('DFI_Snacks.py').read(), myVars)

Then I open experiment_data file in child code matching with id value in append mode using code

os.chdir(r'D:\PhD\Study-I_Part_I\My_Programs\DFI\Participant_Data')
filename=str(id) +'_experiment_data.txt'
experiment_data = open(filename,'a')

This error is coming when Parent code import child code. I don't know where i am going wrong.
Reply With Quote