protobuf
protobuf copied to clipboard
Formally document and support python-protobuf-attribute-setting-by-keyword-argument-to-constructor
For years I've favored writing code shaped like
my_message = my_module_pb2.MyMessage(my_first_attribute=3, my_second_attribute=4)
rather than
my_message = my_module_pb2.MyMessage()
my_message.my_first_attribute = 3
my_message.my_second_attribute = 4
. Are these construction semantics documented anywhere? Could they be, along with the similar semantics of
my_message.repeated_sub_message.add(up='↑', down='↓')
rather than
my_sub_message = my_message.repeated_sub_message.add()
my_sub_message.up = '↑'
my_sub_message.down = '↓'
?
Would this page be the right place for such documentation?
I also find it confusing that the doc indicate this is wrong:
foo = Foo()
foo.bar = Bar() # WRONG!
But this seem to be ok:
Foo(bar=Bar())
I think this is a better place:
https://developers.google.com/protocol-buffers/docs/pythontutorial#the-protocol-buffer-api
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago.
Still a problem. *pokes bot in the eyes*