Skip to content

Formally document and support python-protobuf-attribute-setting-by-keyword-argument-to-constructor #2782

Open
@nathanielmanistaatgoogle

Description

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions