next up previous contents
Next: Mapping for Sequences and Up: OMG IDL to Python Previous: Mapping for Unions   Contents


Mapping for Structures

An IDL structure is mapped into a Python class. The Python class contains a public attribute for each member of the structure. The class's constructor takes a parameter for each member of the structure in the order listed in the IDL.

e.g. consider the following IDL:

module Example {
    struct Foo {
        string bar;
        long baz;
    };
};

In Python the structure can be used as follows:

>>> import Example
>>> struct = Example.Foo("Hello", 99)
>>> struct.bar
`Hello'
>>> struct.baz
99
>>> struct.bar = "Goodbye"
>>> struct.bar
`Goodbye'
>>>