简体   繁体   中英

Get package name for protobuf instance at runtime in python

If I have an instance of a protobuf, is there a way to get the package name from that instance? the docs indicate that

The Python code generated by the protocol buffer compiler is completely unaffected by the package name defined in the .proto file.

Does that mean that there isn't a way to get the package name from a python protobuf instance?

If I had a protobuf object response

print type(response)

prints

<class 'weather_pb2.WeatherReply'>

and

print response.DESCRIPTOR.full_name

prints

weather.WeatherReply

weather being the package name specified where WeatherReply is defined.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM