protocolbuffers/protobuf

Pass key-value pairs into Struct constructor in python

Open

#12.809 aberto em 15 de mai. de 2023

Ver no GitHub
 (5 comments) (0 reactions) (0 assignees)C++ (16.128 forks)batch import
help wanted

Métricas do repositório

Stars
 (71.223 stars)
Métricas de merge de PR
 (Mesclagem média 2d 11h) (185 fundiu PRs em 30d)

Description

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.

Guia do colaborador