Next: 4.13 Client Side Mapping Up: 4. OMG IDL to Previous: 4.11 Mapping for TypeCodes

# 4.12 Mapping for Any

The IDL type `any` is mapped to the Python class `CORBA.Any`. The constructor for this class takes a typecode and a value that conforms to that type. The class also has two corresponding accessor methods `typecode()` and `value()`.

e.g. Using the structure example from Section :

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

An `Any` containing an instance of the structure `Foo` can be constructed and used as follows:

    >>> from Fnorb.orb import CORBA
    >>> import Example
    >>> # Create an instance of the structure.
    ... s = Example.Foo(`Hello', 123)
    >>> # Get the structure's typecode.
    ... tc = CORBA.typecode(`IDL:dstc.edu.au/Example/Foo:1.0')
    >>> # Now create the `Any'.
    ... a = CORBA.Any(tc, s)
    >>> a.typecode()
    <TypeCode.StructTypeCode instance at adc30>
    >>> a.value()
    <Example.Foo instance at adc60>
    >>>