Arguments of function as out

Alex Martelli aleax at
Thu Sep 4 09:44:08 CEST 2003

Birgit Rahm wrote:

> Thank you,
> I've already read this, but I hoped, there is a way to get these out
> parameters beside this.
> Because I cant redesign the function on the server side. So I have only
> the possibility to change the client side code, which calls this function.
> It seems there is no way in python to use it and get the new out paramter
> value after finishing the function.

Birgit, you do not seem to have *READ* the answer to which you are
replying.  Let me quote it again (since you violate netiquette by
this "top-post", putting your response before the text you are
responding to):

>> 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.

Read it again, *CAREFULLY*.  Nothing here requires you to "redesign
the function on the server side": it's only, STRICTLY about what you
do in "the client side code, which calls this function", as you say.

For example: you say you have a function, say X, which has three
arguments, all 'out' parameters, and returns void.  Very well then,
according to the Python language binding which Piet quoted to you,
from the point of view of the Python client code calling X, X is
returning a tuple which packs the three result values!

So, you call it as:

    a, b, c = X()

and that's all!  Note you do NOT pass arguments corresponding to
out parameters (you DO pass arguments corresponding to in and inout
parameters, if any); you get result values corresponding to the
function's nonvoid return if any (none here) followed by all out
and inout parameters.

It ain't all that hard, really...


More information about the Python-list mailing list