How can I check a game Property?
bpy is the Blender API.

The BGE API is bge.

You can access game properties via dictionary access on the game object

Read

Read and fail when it does not exist

print("property value is ", gameObject["propertyName"])


This is the fastest method, but fails when the property is not present. This is good when the property is mandatory.

Read with fallback value

print("property value is ", gameObject.get("propertyName", "fallbackValue"))


This is pretty fail safe and can be used on optional properties. 

Be aware it always creates the fallback value. This costs processing time. Ensure creating the fallback value is fast (or use an existing value). 

The property will not be set, when it does not exist.

Read with previous existence check:

if "propertyName" in gameObject:
    print("property value is ", gameObject["propertyName"])
else:
    print("no property set")


Requires more code but is very fail safe. When the property exists the read access is performed twice (once for check existence, once to get the value). 

It is good when the property is optional and the fallback situation needs some effort (such as creating larger objects) or leads to complete different behavior. The fallback code will only be executed when the property is not existent. This solution is more efficient when in most of the cases the property is not present (as this results in a single read access).

Read with error handling:

try:
    print("property value is ", gameObject["propertyName"])
except KeyError:
    print("no property set")


More code but fail safe. Pretty efficient as the access will happen just once. The fallback can be complex, it will only be executed when the property is not present. 

Write

gameObject["propertyName"] = newValue


It is the exact same code, regardless if you want to add or change a property

Delete

del gameObject["propertyName"]


Example

Initialize Property

try:
    propertyValue = gameObject["propertyName"]
except KeyError:
    propertyValue = "fallbackValue"
    gameObject["propertyName"] = propertyValue 

print("property value is ", propertyValue )


[Edit:]

Getting Game Objects

Just in case you do not know how to get or find game objects:

import bge

v1 = bge.logic.getCurrentScene().objects["v1"] # this will fail when there is no object called v1!
farbe = v1.get("farbe")
print("farbe of v1 is", farbe)