Figuring out the correct context for an operation

Hey everyone,

I would like to run the shape_key_remove command on a list of objects using Python.
A snippet of the code I’m using is below.

    for object in
        if (object.type == "MESH"):
            if (len(list(filter(lambda x : "mbastlab_proxyfit" in, > 0):
                print("Deleting proxy fitting keys from",
                def del_shape_key(name):
                    i =
                    object.active_shape_key_index = i

The problem is, sometimes the code fails due to context issues!
Looking at the documentation for shape_key_remove() I don’t see any notes on what the necessary context is.
What’s the best way to approach the context issue?


Ensure your object is selected and active before operator call (like user will do by hand). = True = object

Thanks @stephen_leger, that’s working perfectly.