Replacement for os command which can work online

I am taking my visual search task online and I have noticed that the second line of the following part where i get the image file path, is not working online. So it does not recognise the os and I get the error of not recognising this variable.

So I am thinking of doing this in a different way. So is there a way I can replace the os.path.join and os.listdir commands?

img_dir = ‘./stimuli/transparent’

get image file path

img_files = [os.path.join(img_dir,i) for i in os.listdir(img_dir) if i.endswith(’.jpg’)]

choice three targets and no target randomly


0-2 are targets and 3 is no target

expInfo[‘par_targets_list’] = img_files[:4]

from third file onwards: distractor

expInfo[‘distractors’] = img_files[4:]

I don’t believe that there is a way of reading the directory listing using PsychoPy online, which is why I suggested an alternative solution in the previous thread.