Deleted objects still exists I manually deleted an object from outliner but my python code still finds that object. Is this because we need to somehow "update" or "synch" the blender's display component with its actual data base?

Thanks!

My python code use bpy.data.curves[0].splines[0] to find the object (a bezier curve). I deleted the first BezierCurve from outliner then added a new BezierCurve object. Then I ran the code through the built-in scripting window. That is when I noticed the operation occurred on the originally deleted BezierCurve.

    import mathutils
    import bpy

    # by zeffi
    # https://github.com/zeffii/rawr/blob/master/blender/scripts/addons_contrib/curve_normalize_spline.py
    def get_points(spline, clean=True):

        knots = spline.bezier_points

        if len(knots) &lt; 2:
            return

        # verts per segment
        r = spline.resolution_u + 1

        # segments in spline
        segments = len(knots)
        print("segments = %d"%segments)
        if not spline.use_cyclic_u:
            segments -= 1

        master_point_list = []
        for i in range(segments):
            inext = (i + 1) % len(knots)

            knot1 = knots[i].co
            handle1 = knots[i].handle_right
            handle2 = knots[inext].handle_left
            knot2 = knots[inext].co

            bezier = knot1, handle1, handle2, knot2, r
            points = mathutils.geometry.interpolate_bezier(*bezier)
            master_point_list.extend(points)

        # some clean up to remove consecutive doubles, this could be smarter...
        if clean:
            old = master_point_list
            good = [v for i, v in enumerate(old[:-1]) if not old[i] == old[i+1]]
            good.append(old[-1])
            return good

        return master_point_list

    spline = bpy.data.curves[0].splines[0]
    points = get_points(spline)

    for i in points:
        bpy.ops.mesh.primitive_uv_sphere_add(size=0.05,location=i)
Objects are "containers" for data. Mesh objects contain mesh data, curve objects contain curve data, etc. When you deleted the curve, you deleted the container, not the data that it contained. So, in your code your operating on the first curve in the curve data block, which would be the original curve.

Some options you have to resolve this are:

a. Delete the curve from the curve data block
 b. Find the curve that the curve object contains, and operate on it.

I would do the later:

curve = bpy.data.objects["curve object's name"].data
spline = curve.splines[0]