Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Rectangle object not iterable

Hi all,
This supposed to be an easy question. I'm trying to looping two different object (rectangle and circle). I've done so far :
stim = {'stim1': expyriment.stimuli.Rectangle([150,150],position = [0,0], colour = expyriment.misc.constants.C_GREEN),
'stim2': expyriment.stimuli.Rectangle([150,150],position = [0,0], colour = expyriment.misc.constants.C_YELLOW),
'stim3': expyriment.stimuli.Circle(radius=100,position = [0,0], colour = expyriment.misc.constants.C_GREEN),
'stim4': expyriment.stimuli.Circle(radius=100,position = [0,0], colour = expyriment.misc.constants.C_YELLOW)}

for st, sm in stim.iteritems():
<expyriment.stimuli._rectangle.Rectangle object at 0x000000000B15D828>
<expyriment.stimuli._rectangle.Rectangle object at 0x000000000B15D908>
<expyriment.stimuli._circle.Circle object at 0x000000000B15D860>
<expyriment.stimuli._circle.Circle object at 0x000000000B15D7F0>

em =
TypeError: 'Circle' object is not iterable

em =
TypeError: The parameter 'list_' is a Circle, but has to be list.

There is a better solution for this problem?


  • Hi Tanto,

    Both the functions work on lists, not the elements of the list. So if, you want to randomly select an item from the list stim, you have to call on the list, not the elements. The same goes for So, you wouldn't need to loop over the items. Does that make sense?


  • Hi Eduard.
    Thanks for your help!.I just realize that.
    I've change dict with list and iterate with "pres_stim = stim[trial]".

Sign In or Register to comment.