Question
Asked By – PaolaJ.
I am using protocol buffers in python and I have a Person
message
repeated uint64 id
but when I try to assign a value to it like:
person.id = [1, 32, 43432]
I get an error: Assigment not allowed for repeated field "id" in protocol message object
How to assign a value to a repeated field ?
Now we will see solution for issue: How to assign to repeated field?
Answer
As per the documentation, you aren’t able to directly assign to a repeated field. In this case, you can call extend
to add all of the elements in the list to the field.
person.id.extend([1, 32, 43432])
This question is answered By – Tim
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0