How can I programatically set a field value by its name for a google protobuffer object in python. I’ve checked the documentation and API, but its just not clear to me, and I haven’t been able to find any examples.
I’d like to do do something like:
protoBufObj.set_field('foo', 42)
Thanks.
If you’ve got any Python object where
x.foo = 42works,setattr(x, 'foo', 42)should have precisely the same effect. This is a built-in Python function, nothing to do with protobuffers.