# AttributeError: 'str' on clickable stimuli

**URL:** <https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768>\
**Category:** Builder\
**Created:** [November 3, 2021, 5:21am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768 "2021-11-03T05:21:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arpitha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/arpitha/32/12877_2.png) [@Arpitha](https://discourse.psychopy.org/u/Arpitha)\
**Post date:** [November 3, 2021, 5:21am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/1 "2021-11-03T05:21:31Z")

</div>

![Screenshot 2021-11-03 at 13.21.04](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/5/e543d295f2571ccfc243479964b40e69aa79c00d.jpeg)

**OS** (e.g. Win10): Mac M1  
**PsychoPy version** (e.g. 1.84.x): 2021.2.3  
**Standard Standalone? (y/n)** If not then what?:  
**What are you trying to achieve?:**. I’m building an experiment where images pop on the screen one at a time and the response has to be made by mouse or touch.

**What did you try to make it work?:**  
I have a condition file with - image column to present the images in spatial order and a valid column for reference of valid click.

**What specifically went wrong when you tried that?:** the image is present but the mouse click is not working. Exp ends with attribute error.

Include pasted full error message if possible. “That didn’t work” is not enough information.

There is an [AttributeError: ‘str’ object has no attribute ‘contains’], How to fix this?

if obj.contains(click\_response):  
AttributeError: ‘str’ object has no attribute ‘contains’

##### Experiment ended.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 3, 2021, 8:50am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/2 "2021-11-03T08:50:19Z")

</div>

Is image the name of the image component or a column in your spreadsheet?

---

<div class="post-metadata">

**Author:** ![Arpitha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/arpitha/32/12877_2.png) [@Arpitha](https://discourse.psychopy.org/u/Arpitha)\
**Post date:** [November 3, 2021, 9:17am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/3 "2021-11-03T09:17:13Z")

</div>

“image,” is the name of the column in my spreadsheet. I put the clickable stimuli as “image,” because I want the responses for all images that appear from that column.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 3, 2021, 9:31am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/4 "2021-11-03T09:31:38Z")

</div>

You need to put the name of the image component that shows image rather than the file name, which is a string.

Also, if you move online, you will probably need to use a different name for your variable – but it should be fine locally.

---

<div class="post-metadata">

**Author:** ![Arpitha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/arpitha/32/12877_2.png) [@Arpitha](https://discourse.psychopy.org/u/Arpitha)\
**Post date:** [November 3, 2021, 9:58am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/5 "2021-11-03T09:58:23Z")

</div>

The name of the image component here was ‘target’, when I put that in clickable stimuli, it worked 🙂 Thank you very much!!  
I’m also curious to know more about your suggestions for a change of the variable name if I push it online. Why is that?

Thanks

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 3, 2021, 11:05am UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/6 "2021-11-03T11:05:28Z")

</div>

Here’s a quote from my crib sheet.

**Don’t** Use simple terms for variables, since they may already be in use by PsychoPy. Variable names to avoid are: class, core, image, index, Length, list, Object, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.

> **[PsychoPy Python to Javascript crib sheet 2021](https://docs.google.com/document/d/183xmwDgSbnJZHMGf3yWpieV9Bx8y7fOCm3QKkMOOXFQ/edit?usp=sharing)**
>
> PsychoPy version 2021.1.3-2021.2.2Python to JavaScript Crib Sheet Compiled by Wakefield Morys-Carter, Oxford Brookes UniversityPlease share widely and follow Psych\_Stats on twitter. PsychoPy 2021 is a major update with several new features. When...

---

<div class="post-metadata">

**Author:** ![Arpitha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/arpitha/32/12877_2.png) [@Arpitha](https://discourse.psychopy.org/u/Arpitha)\
**Post date:** [November 4, 2021, 5:18pm UTC](https://discourse.psychopy.org/t/attributeerror-str-on-clickable-stimuli/25768/7 "2021-11-04T17:18:21Z")

</div>

I see, thanks for sharing this fabulous g-doc! Very helpful!.
