Using google reflection protobuffers in python

How can I programmatically set the value of a field by its name for a google protobuffer object in python. I checked the documentation and the API, but it was just not clear to me, and I could not find any examples.

I would like to do something like:

protoBufObj.set_field('foo', 42)

Thank.

+3
source share
1 answer

If you have any Python object where it x.foo = 42works, it setattr(x, 'foo', 42)should have exactly the same effect. This is a built-in Python function that has nothing to do with protobuffer.

+5
source

All Articles