protocolbuffers/protobuf

Pass key-value pairs into Struct constructor in python

开放

#12,809 创建于 2023年5月15日

 (5 条评论) (0 个反应) (0 位负责人)C++ (16,128 个派生)batch import
help wanted

仓库指标

星标
 (71,223 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

What language does this apply to? python

Describe the problem you are trying to solve. When we initialise a Struct and want to set key-value pair on the struct, there are two steps:

struct = Struct()
struct.update(key1='value-1', key2=2)

Alternatively, we can also use json_format.ParseDict.

Describe the solution you'd like Hopefully, we can do the following:

struct = Struct(fields={'key1': 'value-1, 'key2: 2})
# or 
struct = Struct({'key1': 'value-1, 'key2: 2})

Describe alternatives you've considered

Additional context Add any other context or screenshots about the feature request here.

贡献者指南