Scripting - How to create a game property? I have a bunch of objects and need to create some common properties to all of them like this

for ob in bpy.data.objects:
    if ob.name.find("someName") &gt;= 0:
        theObject = ob.game
        ...create new property in theObject, and set value
        ...create new property in theObject, and set value
        ...create new property in theObject, and set value
        ...create new property in theObject, and set value


The result should show the properties added to every object "someName" (someName.001, someName.002, etc) in the Logic Editor like this
There's the object.game.properties collection, but it doesn't seem to have a new method. You can use an operator to create the property, though, and then modify the value:

for ob in bpy.context.scene.objects:
    if ob.name.find("someName") &gt;= 0:
        # Set active object first so operator works on the right one
        bpy.context.scene.objects.active = ob
        bpy.ops.object.game_property_new(type='STRING', name='foo')
        prop = ob.game.properties['foo']
        prop.value = 'bar'


I'm pretty sure the items in the list are kept in the order they are created, so you can also access the most recently-created property with ob.game.properties[-1].