# Deprecated API
bpy.ops.object.delete({"selected_objects": objects_to_delete})

# New API
with context.temp_override(selected_objects=objects_to_delete):

This is stated in the 3.2 release notes.

Currently, on 3.1, I am deleting objects like so:

bpy.data.objects.remove(my_object, do_unlink = True)

Im curious of 2 things now:

  • Does this change affect my current script?
  • Am I deleting stuff the wrong way?

1 Answer 1


The API change only affects operators. If the start of your line begins with bpy.ops, you're using an operator. Otherwise, you're not.

Operators are meant to be used in the user interface, but they can also be called by script. However the script has to provide additional information which would otherwise be provided by the interface context otherwise. (eg the selected objects in the 3D viewport).

Here you are using a lower-level API call to directly affect the bpy.data.objects container, so you don't have to change anything. Your method is the preferred one since it's (usually) more efficient to use lower level functions than using operators.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .