Dynamically creating python class from protobuf file at runtime?

In Python, is it possible at runtime to convert the Google Protocol log file .prototo a python class that reads this data? Python is a very dynamic language. When you use python protocto convert the file .prototo the source code, the generated code uses python metaclasses a lot, so it is already very dynamic.

Ideally, I think of something like this:

import whatever
module = whatever.load_from_file("myfile.proto")

Is it possible?

(I'm new to protocol buffers, please let me know if my question doesn't make sense)

+4
source share
2 answers

, . Python protobuf ++ .proto (libprotoc) C , .

, , . ( : , , , , , .)

, Cap'n Proto. Python , , , . , Protobuf.

( : Protobuf Google, Cap'n Proto.)

+6

init.py. .: __init__.py ?

script Python init.py. script Python.

0

Source: https://habr.com/ru/post/1628324/


All Articles