How to check if an object has a custom property with python?
There are two types of custom properties:


Properties global to a type, bpy.props.* for e.g. bpy.types.Object
(ob.char = "foobar")
ID properties local to a type instance
(ob["char"] = "foobar")




To test for bpy.props properties / attributes:

hasattr(ob, "char")


Or get the attribute:

# note: throws AttributeError if not existing
getattr(ob, "char") 

# don't throw exception but return default (None) value if not existing
getattr(ob, "char", None)




To test for a certain ID property, use:

bpy.data.objects['Object'].get('char') is not None


get() returns the value of the custom property assigned to the given key (the property name), or None if it couldn't find the key. You can make it return anything in case the key doesn't exist, like a string:

Object.get('char', default="Not found.")