python - Program not recognizing repeated composite container in protobuf? -
python - Program not recognizing repeated composite container in protobuf? -
i have protobuf repeated field of people stored within address book.
so far, start things off this:
addressbook = book() jake = addressbook.persons.add() jake.phone = 33333 lucy = person() lucy.phone = 44444 taylor = person() taylor.phone = 55555 addressbook.persons.extend([lucy, taylor])
i have file that's supposed go through addressbook , compare addressbook see if it's same addressbook. far, this:
#book_vars variables within address book, people item in book_vars: if isinstance(getattr(book1, item), collections.iterable: stuff
however, never goes if loop. have ideas why?
the class protobufs uses represent repeated fields not python native list type , not inherit collections.iterable
, hence code not observe repeated fields intend. improve way tell type of each field in protobuf message utilize descriptor, available mymessagetype.descriptor
.
python protocol-buffers
Comments
Post a Comment