Deleting Shapes and not traces by name

I am looking to translate this line of code to something usable for shapes instead of traces.

figure.data = [trace for trace in figure.data if not trace.name.startswith(‘Patch’)]

Something like this, but these lines of code didn’t work

// Doesn’t work
other_shapes = [shape for shape in figure.layout.shapes if not shape[‘name’].startswith(‘Patch’)]

figure.update_layout(shapes=other_shapes)
//

Thank you

Hey @danapol welcome to the forums.

Some while ago I did just that. Take a look at this: