How to assign a value to an embedded message field in Protocol buffer Python -
i have following proto , trying assign value embedded message field
message foo { required bar bar = 1; } message bar { optional int32 = 1; }
when writing following code in python, gives below error
foo = foo() foo.bar.i = 1
error:
attributeerror: 'instancemethod' object has no attribute 'i'
how deal error?
to want, in python, have define bar
method within foo
class. it:
class foo: = 1 def bar(self): return self.i if __name__ == '__main__': foo = foo() foo.bar = 1 print(foo.bar) # print 1
Comments
Post a Comment