On Friday, June 8, 2012 10:56:12 AM UTC-7, JeffD wrote:
>
> #!/usr/bin/env python
>
> import foobar_pb2
>
> # protoc -I=. --python_out=. foobar.proto
>
> # message Bar {
> #   optional int32 i = 1 [default = 0];
> #   optional int32 j = 2 [default = 0];
> # }
> # message Foo {
> #   repeated Bar bars = 1;
> # }
>
> foo = foobar_pb2.Foo()
> # ok, but not reflection
> #foo.bars.add()
>

got it:

bars = getattr(foo, 'bars')
bars.add()

bars[0].i = 37

print foo.bars[0]

# prints i: 37

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/dxqSvx_8g04J.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to