Arguments of function as out

Jeff Epler jepler at unpythonic.net
Thu Sep 4 09:42:43 EDT 2003


On Thu, Sep 04, 2003 at 07:51:15AM -0500, Jeff Epler wrote:
> I found this result when searching for 'omniorbpy "out parameter"':
>     http://www.omniorb-support.com/pipermail/omniorb-list/2000-April/015244.html
> I don't know for certain that this is the way omniorbpy behaves today,
> but it is a very pythonic way to work.
[...]
> | I recommend that you read the mapping specification, which you can
> | download from
> | 
> |   http://www.omg.org/cgi-bin/doc?ptc/00-01-12

[Replying to my own post]

The current version of that document can be retrieved from 
http://www.omg.org/technology/documents/formal/python.htm
-> http://www.omg.org/cgi-bin/doc?formal/02-11-05
-> http://www.omg.org/cgi-bin/apps/doc?formal/02-11-05.pdf
or http://www.omg.org/cgi-bin/apps/doc?formal/02-11-05.ps

Page 1-12 discusses the treatment of "out" and "inout" parameters and
the mapping onto Python return values:

    Operations of an interface map to methods available on the object
    references.  Parameters with a parameter attribute of in or inout are
    passed from left to right to the method, skipping out parameters. The
    return value of a method depends on the number of out parameters
    and the return type. If the operation returns a value, this value
    forms the first result value. All inout or out parameters form
    consecutive result values. The method result depends then on the
    number of result values:
      . If there is no result value, the method returns None.
      . If there is exactly one result value, it is returned as a
        single value.
      . If there is more than one result value, all of them are packed
        into a tuple, and this tuple is returned.

    Assuming the IDL definition

        interface I{
            oneway void stop();
            bool more_data();
            void get_data(out string name,out long age);
        };

    a client could write

        names={}
        while my_I.more_data():
            name,age = my_I.get_data()
            names[name]=age
            my_I.stop()

Jeff





More information about the Python-list mailing list