from google.protobuf import text_formattext_format.MessageToString(your_protobuf_object)
Note that you can also just do str(message_object) to get the same result. The interesting part about the text_format module is that it can also parse this format back into a message object (as of v2.2.0), and the C++ and Java runtimes also support parsing and writing the same format via their TextFormat classes. Works great for human-editable config files.
Post a Comment