iRec.ROFields is a struct called 'msgROFields' with one element,
ROField (a list).
You should be able to say:
iRec.ROFields.ROField.append(msgROField())
However, I think it would be more idiomatic to specify either
typedef list<msgROField> msgROFields
or specify InstitutionRecord as
{
1: string REC_ID;
2: i32 NumROFields;
3: msgInstitution Institution;
4: msgCSA CSA;
5: list<msgROField> ROFields;
}
instead of:
struct msgROFields
{
1: list<msgROField> ROField;
}
Michael
On Sun, Jun 7, 2009 at 4:10 PM, Joshua Kramer<[email protected]> wrote:
> Hello,
>
> Does anyone have an example of how to use Lists in python? I have an IDL
> file like this:
>
> struct msgROField
> {
> 1: string Name;
> 2: double Value;
> }
>
> struct msgROFields
> {
> 1: list<msgROField> ROField;
> }
>
> struct InstitutionRecord
> {
> 1: string REC_ID;
> 2: i32 NumROFields;
> 3: msgInstitution Institution;
> 4: msgCSA CSA;
> 5: msgROFields ROFields;
> }
>
> I can use the structures, except for the msgROFields. As I use the
> InstitutionRecord object, I assign the objects appropriately - i.e.:
>
> iRec = InstitutionRecord()
> iRec.ROFields = msgROFields()
>
> My problem is this. I cannot add do something similar to this:
>
> iRec.ROFields.append(msgROField())
>
> If I inspect the data structure in a debugger, I see that there is *one*
> ROField element under the ROFields structure. But there's no way to do the
> standard Python list operations on either the ROFields or ROField elements.
>
> Any ideas?
>
> Thanks!
> -Josh
>
>