What steps will reproduce the problem?
1. Define a protobuf message that uses a repeated field.
2. Compile the protobuf to python code.
3. Attempt to search for a value in the repeated field "list" using the "index"
function.
What is the expected output?
Return the matching value from the repeated field list, or ValueError as
appropriate. (The specified behavior of the "index" function.)
What do you see instead?
AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute
'index'
What version of the product are you using? On what operating system?
Protoc 2.5 on Windows 7.
Please provide any additional information below.
Repeated fields purport to generally function as python lists, in the duck
typing sense. Not implementing support for something relatively basic like the
"index" function definitely violates the principle of least surprise.
It appears that the solution would be as straightforward as adding the
following method definition to RepeatedScalarFieldContainer in containers.py:
def index(self, elem):
"""Finds the index of a given item in the list. Similar to list.index(elem)."""
return self._values.index(elem)
Original issue reported on code.google.com by ajkinn...@gmail.com on 10 Jul 2014 at 7:11
Original issue reported on code.google.com by
ajkinn...@gmail.com
on 10 Jul 2014 at 7:11