Loop error (AttributeError: 'NoneType' object has no attribute 'keys')

2,491 views
Skip to first unread message

jacobz

unread,
Jan 29, 2012, 5:09:33 PM1/29/12
to psychopy-users
Hi, I'm using the builder with the most recent version (1.73.2) and
I'm getting the following error:

stimOut=trials_2.trialList[0].keys(),
AttributeError: 'NoneType' object has no attribute 'keys'

I have a simple routine with just an image and text, and a loop
without a conditions file. Does anyone know what is causing this
error? I can post the file if it's helpful.

Thanks!

Christopher Cox

unread,
Jan 29, 2012, 5:25:57 PM1/29/12
to psychop...@googlegroups.com
> stimOut=trials_2.trialList[0].keys(),
Breaking down the source of the error, you have an object (trials_2) that includes in its scope a list (trialsList). The keys() method is being applied to the first element of trialList (trialList[0]). The error is telling you that the element referenced by trialList[0] is a None Type, which basically means that the slot in the list is empty.

There is no way of knowing why it is empty without seeing more of your code.

> --
> You received this message because you are subscribed to the Google Groups "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.
>

---
Chris Cox

Language and Cognitive Neuroscience &
Knowledge and Concepts Labs
UW-Madison
cr...@wisc.edu
lcnl.wisc.edu/people/ccox

jacobz

unread,
Jan 29, 2012, 9:56:00 PM1/29/12
to psychopy-users
Thanks Chris,

It seems that within the builder a loop requires a conditions file,
even if it's not used. By adding a conditions file with a dummy
parameter, I'm able to get rid of the error. Not sure if that's a bug
or if there's a reason for it being there.



On Jan 29, 4:25 pm, Christopher Cox <cox....@gmail.com> wrote:
> > stimOut=trials_2.trialList[0].keys(),
>
> Breaking down the source of the error, you have an object (trials_2) that includes in its scope a list (trialsList).  The keys() method is being applied to the first element of trialList (trialList[0]).  The error is telling you that the element referenced by trialList[0] is a None Type, which basically means that the slot in the list is empty.
>
> There is no way of knowing why it is empty without seeing more of your code.
>
> On Jan 29, 2012, at 4:09 PM, jacobz wrote:
>
>
>
>
>
>
>
>
>
> > Hi, I'm using the builder with the most recent version (1.73.2) and
> > I'm getting the following error:
>
> > stimOut=trials_2.trialList[0].keys(),
> > AttributeError: 'NoneType' object has no attribute 'keys'
>
> > I have a simple routine with just an image and text, and a loop
> > without a conditions file. Does anyone know what is causing this
> > error? I can post the file if it's helpful.
>
> > Thanks!
>
> > --
> > You received this message because you are subscribed to the Google Groups "psychopy-users" group.
> > To post to this group, send email to psychop...@googlegroups.com.
> > To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/psychopy-users?hl=en.

Jonathan Peirce

unread,
Jan 30, 2012, 4:31:53 AM1/30/12
to psychop...@googlegroups.com
That's a bug. It /should/ be a perfectly reasonable thing to have trials
simply repeat with nothing changing, so no conditions file. Your
workaround is the right one, but I should be able to fix the behaviour
properly.

Jon

--
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk


This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

Jonathan Peirce

unread,
Jan 30, 2012, 10:59:48 AM1/30/12
to psychop...@googlegroups.com
This is now fixed in the repository. You need a new copy of
    psychopy/app/builder/experiment.py
which you can fetch from here:
    https://github.com/psychopy/psychopy/commit/bf220c3937c6b2afddc45d48ed893de6399d166d

(follow the links to the raw file)


Jon

On 30/01/2012 02:56, jacobz wrote:
Reply all
Reply to author
Forward
0 new messages