user45245
user45245

Reputation: 905

gRPC Analog of C # MessageDescriptor Parser in Python

I am looking for. Analog of C # MessageDescriptor Parser in Python. For example. I am trying port this C# code to Python. But unfortunately in python implementation of MessageDescriptor is not field Parser. How I can get parser in Python implementation

foreach (var msg in fd.MessageTypes)
{
    var name = fd.Package + "." + msg.Name;
    TypeLookup.Add(name, msg.Parser);
}

Upvotes: 0

Views: 123

Answers (1)

Jie Luo
Jie Luo

Reputation: 36

In python, you can call msg.ParseFromString() directly on the message.

https://github.com/protocolbuffers/protobuf/blob/0adb74c2d36833be37b35a9ab45e4f699a1d645c/python/google/protobuf/message.py#L181

Upvotes: 1

Related Questions