What's the proper way to set a google.protobuf.Int32Value in python?

1.6k views Asked by At

I'm using Google's Int32Value protobuf in python. I'm wondering what the proper way to set the value is. If we do it during initialization, then we can do

my_int_32_value = Int32Value(value=123)

If we try to set it after initialization, then is this the proper way?

from google.protobuf.wrappers_pb2 import Int32Value

my_int_32_value = Int32Value()
my_int_32_value.value = 123

It seems to work, but also feels wrong to directly access the attribute like that, not via a setter.

EDIT: For instance, to set a Timestamp after it has been created, you can invoke the FromDateTime function, or some version of MergeFrom or CopyFrom

0

There are 0 answers