How to delete all faces with distance to other object
This code does the trick, and uses some nice built in functions to make things simpler:

import bpy, bmesh

s = bpy.data.objects['Sphere']
o = bpy.context.object

bpy.ops.object.mode_set(  mode   = 'EDIT'     )
bpy.ops.mesh.select_all(  action = 'DESELECT' )
bpy.ops.mesh.select_mode( type   = 'FACE'     )

bm = bmesh.from_edit_mesh( o.data )

for f in bm.faces:
    # Calculate the global location of the current face's median point
    gCenterMedian = o.matrix_world * f.calc_center_median()

    # Find the closest point on the Sphere to the current face's median
    loc = s.closest_point_on_mesh( gCenterMedian )[0]

    # Find the distance by calculating the length of the vector between the two points
    distance = ( loc - gCenterMedian).length

    if distance &lt; 0.5: f.select = True

bm.select_flush( True )

# Delete all selected faces
bpy.ops.mesh.delete( type = 'FACE' )

bpy.ops.object.mode_set( mode = 'OBJECT' )


As the gif shows, reverse the sign to delete far away faces