PsychoPy version: 2021.2.3
I’m a newer to PsychoPy, and want to achieve a nested loop with many inner loops. In the official instruction, I should have an Excel to store the name of the inner loop table. However, could I use only 1 excel to achieve the nested loop like this?
condition con1 con2
con1 1 2
con2 2 3
In the first column are the variable names needed for the inner loop, and the other columns are the corresponding conditions. I want to fetch the specific conditions of the other columns by reading the variable names of the first column. I have tried to use “$$condition”, but the second “$” was recognized as a char.
So, could PsychoPy achieve the function?
I feel like this way of doing it is very confusing, but if it has benefits for you, you might be able to do it with eval(condition). This takes the value of your condition variable (which is a character), interprets it as a variable name, and outputs the value of this variable. I never used it though, so not sure if it works.
I use code such as
if thisCondtion == 1:
thisImage = Colour
elif thisCondition == 2:
thisImage = Shape
thisImage = Number
where Colour, Shape and Number are different columns in the Excel
Thank you for your reply. I realized it was very confusing after I asked. Why I asked this is that I have many conditions, like 100, but I don’t want to build 100 Excel tables to store them.
Thanks for your reply. I’m going to learn how to use code.