Look at the object type.
@thibsert has answered the question at hand, Given
I need to this condition to filter out invalid objects for join()
.
feel this is somewhat of an XY Problem
If you are joining objects, suggest looking at the Object.type
property, since can only join objects of the same type. For example sake let's assume you are joining mesh objects.
All selected mesh objects
mesh_obs = [o for o in context.selected_objects if o.type == 'MESH']
ie only interested in meshes, or to filter out non meshes
if ob.type != 'MESH':
# continue
Similarly all empties in scene, regardless of empty display type
empties = [o of o in context.scene.objects if o.type == 'EMPTY']
ie as demonstrated ob.data is None
is not a sufficient test for empties since the advent of reference images. Testing for obj.empty_display_type
without knowing the object is an empty will throw an error. Hence a robust test for ref image object is
obj.type == 'EMPTY' and obj.empty_display_type == 'IMAGE'