Next: 4.12 Mapping for Any Up: 4. OMG IDL to Previous: 4.10 Mapping for Exceptions

# 4.11 Mapping for TypeCodes

The TypeCode interface is defined in the CORBA 2.0 specification [1] and is mapped to Python in the usual manner. Similarly, typecode constants for all of the standard IDL datatypes are defined in the `CORBA` module. The typecodes for user-defined types are accessed using the method `CORBA.typecode()`. The `CORBA.typecode()` method takes a single parameter that is the interface repository identifier of a user-defined type, and returns its corresponding typecode. e.g. Using the enumeration example from section :

    Module Example {
        enum color {red, green, blue};
    };

The typecode for the `color` enumeration can be accessed and used as follows:

    >>> from Fnorb.orb import CORBA
    >>> import Example
    >>> tc = CORBA.typecode(`IDL:dstc.edu.au/Example/color:1.0')
    >>> tc
    <TypeCode.EnumTypeCode instance at adae0)
    >>> for i in range(tc.member_count()):
    ...      print tc.member_name(i)
    ...
    red
    green
    blue
    >>>