I have a protobuf message that contains a repeated field. I would like to remove one of the items in the list but I can't seem to find a good way to do so without copying all of the items out of the repeated field into a list, clearing the repeated field, and repopulating it.
In C++ there is a RemoveLast()
function, but this doesn't seem to appear in the python API...
As noted in the documentation, the object wrapping a repeated field in Protobuf behaves like a regular Python sequence. Therefore, you should be able to simply do
del foo.fields[index]
For example, to remove the last element,
del foo.fields[-1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With