I keep getting this error message enter image description here

What am I doing wrong?

enter image description here

  • $\begingroup$ The error messages relates to the BGE-Python binding (CList). So this is a valid question. It is even a message that can happen quite often. $\endgroup$
    – Monster
    Nov 18, 2016 at 5:55
  • $\begingroup$ @Monster Thank you for your help Monster! Super appreciate it. Sorry if it was a super nooby question. $\endgroup$
    – Eli
    Nov 18, 2016 at 10:26
  • $\begingroup$ @batFINGER Apologies if this was annoying to read. Being new is no excuse. Even though I had looked around for this specific question, it wouldn't hurt to read up more on python so I don't bug you guys with silly questions. If it helps other users, I really don't mind you downvoting. Thanks for your help! $\endgroup$
    – Eli
    Nov 18, 2016 at 10:45

2 Answers 2


As often the Python errors tell pretty much. Unfortunately they do not necessarily match what we expect. So it is pretty easy to miss the important content of the message.

Luckily when you read the error text twice or more you can get an idea what the problem is.

So here is an insight:

What happened?

Message text

(you can ignore the stack trace at that stage):

key not in list

as simple as it sounds ...

  • there is a list.

  • there is an access by key.

  • this key is not in this list.

Message details

"restriction" ...

Here it is the specific key used at that operation

The code tries tho access a list by key "restriction". The error tells there is no item with key "restriction".

Where did it happen?

Logic brick

Python code can be used at various different Python controllers. The error occurred at a specific one. Often you need the context of the controller to investigate into the error situation. For example the owning object misses a property, while it is present at another object.

Unfortunately you skipped that line. So I show you a sample from my file:

Python script error - object 'Cube', controller 'Python':

This is important info:

  • The owning object (owner) is called "Cube"

  • The controller is called "Python"

Now you know the context.

Source code

Here you need the stack trace. The last entry tells you what file and what line of that file causes the error.

Be aware if there are several operations at that line, it can't tell you. Therefore it is a good idea to have as less operations as possible at a single line. Just in case there is an error with one of them.

File "Untitled"

This is typically a textblock - in your case text block "Untitled"(Hint: a more descriptive name will help you later).

line 18

The line in the source code


This means you are running in script mode ... there is no explicit module to name. Therefore it is called . You can ignore it.

Now you know where to look a the code.

Line 18 of "Untitled" is:

obj0 = scene.objectsInactive['restriction']


You know from the information above that "restriction is not in a list. The list is not named in the error message. So we check the source code to identify lists.

There is only one list:


We can conclude: There is no item with key "restriction".

What do we know about that objectsInactive?


A list of objects on background layers (used for the addObject actuator), (read-only)

Not really helpful as there are no "background layers" in the BGE. The name "objectsInactive" is more helpful here. It is a list of inactive objects.

When you have a bit of experience with the BGE, then you learned that you can access items from the list via name. That is what you did.

So you can conclude

-> There is no object called "restriction" in the list of inactive objects

-> There is no inactive object "restriction" in the scene.

-> There is no object "restriction" at an hidden layer of the current scene


I suggest you check your file if that is the case.

  • Maybe the layer this object is living in is enabled.

    • -> disable the layer
  • Maybe you wanted to access active objects

    • -> in your code change scene.objectsInactive to scene.objects

I hope this helps

  • $\begingroup$ Perhaps a note on using blender.org/api/blender_python_api_current/… would be useful. $\endgroup$
    – batFINGER
    Nov 18, 2016 at 6:41
  • $\begingroup$ Usually I would say, yes it is. But ... this is an awful page (maybe it is simply a dirty implementation). Some problems here: The error says the list is a "CList", the object type is "CListValue" - in my eyes "CList" makes much more sense as it indicates a container. The doc page does not explain the item access list[key]. So I do not really want it here. $\endgroup$
    – Monster
    Nov 18, 2016 at 7:15
  • 1
    $\begingroup$ ro = scene.objectsInactive.get("restriction", None) lets us test later whether ro is None (ie there is no "restriction" object), was my point, not the link per-say. $\endgroup$
    – batFINGER
    Nov 18, 2016 at 13:05
  • $\begingroup$ late answer: yes this is possible, but is it an expected situation? You add a check if missing that object is an expected situation and the code handles it. If the object should exist it is valid to throw an error as any further code will not be valid and lead to unexpected and hard-to-investigate side effects. $\endgroup$
    – Monster
    Dec 1, 2016 at 13:15

You can try print(scene.objects) or print(scene.objectsInactive)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .