protocolbuffers / protocolbuffers/protobuf

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

Open
#2,782 17 comments 19 reactions 1 assignee View on GitHub

@anandolee is already working on this.

Since May 5, 2026.

documentation enhancement keep open python
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.