Hi,

I'm new to python, and hence, to encoding messages in python. I have a 
proto as follows:


message Configuration {

  enum Events {

      SET_MODE = 10;
      START_TIMER = 12;
      STOP_TIMER = 6;
  }

     message Timer {
        
            repeated Events events = 1 [packed = true];
     }

   required Timer timer = 1;

}


In python, I would have something like:


import configuration_data_pb2
from google.protobuf.internal import encoder

config = configuration_data_pb2.Configuration()

config.timer.events.extend([10, 12])

f = open("ConfigModes.bin", "wb")
serializedMessage = config.SerializeToString()
f.write(serializedMessage)
f.close()


The encoding is accomplished just fine. Since I am not an expert in python, 
nor do I know very well what's inside configuration_data_pb2, I would like 
to know if there is any way I could fill up the events somewhat like this:

config.timer.events.extend([SET_MODE, START_TIMER])

--
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to