Primitive wrappers in Python for Protobuf

Viewed 3851

I'm using proto3 and have a message in some .proto file defined as:

message Response {
  google.protobuf.BoolValue field = 1;
  ...
}

In order to initialize Response in Python, I need to create a boolean primitive wrapper and attach some value.

If I were to initialize this value to True, this is fine. From a Python notebook:

In [52]: from google.protobuf import wrappers_pb2 as wrappers
         boo = wrappers.BoolValue(value=True)
         boo

Out [52]: value: true

If I were to initialize this value to False, no wrapped object is created:

In [52]: from google.protobuf import wrappers_pb2 as wrappers
         boo = wrappers.BoolValue(value=False)
         boo

Out [52]: 

How can create a BoolValue initialized to false?

1 Answers
Related