The "Any" type is not very well documented in the Python documentation

29 views
Skip to first unread message

Shio Tse

unread,
Jun 18, 2019, 11:02:42 PM6/18/19
to Protocol Buffers
The only mention in the "Python Generated Code" page for the Any message type is here. It goes through the basic usage and showcases exactly one use of the Pack, Unpack and Is methods.

However, I see no mention of the type_url and name fields unless I go into the descriptor of the message in the REPL or I inspect the descriptor. The epydoc index does not contain any (heh) mention for Any either.

However, when I tried to search for the message type on Google, I found that the class was documented clearly for at least C# and Java.

Is there simply an oversight in not including google.protobuf.any_pb2 into the documentation?

Shio

Hao Nguyen

unread,
Jun 25, 2019, 10:02:26 AM6/25/19
to Protocol Buffers
Any is a special type that contains a string type_url field and a bytes value field. However, you normally shouldn't touch those fields directly, but instead you should use PackUnpack and Is methods for your Any type. Those fields represent how the data is transferred over the wire, but not necessarily something that you would want to access as part of the API.
Reply all
Reply to author
Forward
0 new messages