BGE python help(list)

Hello, let’s say I have objects in a scene and they all have the same property. If one of the object’s properties is a different value than another, is it possible to detect that without defining the object itself that had its property changed? I need this for creating a simpler method of an inventory where the icons find an empty slot. Thanks.

for example:

slots = [obj for obj in s.objects if ‘slot’ in obj]

if slots[‘path’] == 0:
do something

But this just gives me an error.
I need the [‘path’] property value to be detected across all objects in the list with that property.

why are you checking for 'slot' in obj when you say you’re trying to detect “path”?

The objects have ‘slot’ for a float. Either way it’s the same outcome of an error.
I’m trying to detect the property ‘path’, for the objects that have the float ‘slot’.

and that error is…


you’re trying to access ‘slots’ like it’s a dictionary, but it’s a list. what are the contents of “slots” after your list comprehension?

I’m unsure on how to use a list properly in python; so I only know how to get objects in a scene but not access their properties as a whole at once. If that’s possible?

import bge
cont = bge.logic.getCurrentController() 
Prop = own.scene.objects['someObject']['propName']

What are you trying to do?