473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Arguments of function as out


Hallo Newsgroup,

I have the following problem:
I work with Python 2.2 and invoke functions via CORBA ( I use
onmiORB/omniORBpy) on a server.
The server provides me a function, where the 3 arguments are out-arguments
and the return is void / None.
How can I get these out arguments?
I have read that every argument is seen as local to the function and can not
be used as return value.
(I can't redesign the server function.)
Can I make the 3 arguments global before they were used in the function?
Does this help me?
Or what can I do?

TIA, Birgit

Jul 18 '05 #1
8 4547
>>>>> "Birgit Rahm" <br**@yahoo.d e> (BR) wrote:

BR> Hallo Newsgroup,

BR> I have the following problem:
BR> I work with Python 2.2 and invoke functions via CORBA ( I use
BR> onmiORB/omniORBpy) on a server.
BR> The server provides me a function, where the 3 arguments are out-arguments
BR> and the return is void / None.
BR> How can I get these out arguments?
BR> I have read that every argument is seen as local to the function and
BR> can not be used as return value.
BR> (I can't redesign the server function.)
BR> Can I make the 3 arguments global before they were used in the function?
BR> Does this help me?
BR> Or what can I do?

This is described in the Python language binding:

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.
--
Piet van Oostrum <pi**@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.***********@h ccnet.nl
Jul 18 '05 #2

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
"Piet van Oostrum" <pi**@cs.uu.n l> schrieb im Newsbeitrag
news:wz******** ****@nono.cs.uu .nl...
>> "Birgit Rahm" <br**@yahoo.d e> (BR) wrote:

BR> Hallo Newsgroup,

BR> I have the following problem:
BR> I work with Python 2.2 and invoke functions via CORBA ( I use
BR> onmiORB/omniORBpy) on a server.
BR> The server provides me a function, where the 3 arguments are

out-arguments BR> and the return is void / None.
BR> How can I get these out arguments?
BR> I have read that every argument is seen as local to the function and
BR> can not be used as return value.
BR> (I can't redesign the server function.)
BR> Can I make the 3 arguments global before they were used in the function? BR> Does this help me?
BR> Or what can I do?

This is described in the Python language binding:

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.
--
Piet van Oostrum <pi**@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.***********@h ccnet.nl

Jul 18 '05 #3
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...
Alex

Jul 18 '05 #4

Hallo Alex,
I hope this posting is near to the netiquette.
Birgit, you do not seem to have *READ* the answer to which you are
replying. I dont understood this in the you described it.
* If there is more than one result value, all of them are packed into a
tuple, and this tuple is returned.

I've read this, but I thought that this tuple is returned with the
return statement. I am new to python and I never seen such
a constract:
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.


I have had only the IDL and the py File from the IDL,
were stand take *args and return the return value.
In none of my python books such a construct is described. I'm sorry.

Thanks for helping me,
Birgit
Jul 18 '05 #5
Birgit Rahm wrote:

Hallo Alex,
I hope this posting is near to the netiquette.
Perfect, thanks!

Birgit, you do not seem to have *READ* the answer to which you are
replying.

I dont understood this in the you described it.
>> * If there is more than one result value, all of them are packed into
>> a
>> tuple, and this tuple is returned.

I've read this, but I thought that this tuple is returned with the
return statement. I am new to python and I never seen such
a constract:


The code that implements this CORBA spec (if it is Python code -- it
is quite possible to implement CORBA brokers in Python, and it has
been done) will quite likely use the return statement for this, yes,
of course. But when you CALL the code, you don't need to worry
whether it uses a return statement or some other black magic: you
can code your call AS IF the code you called was Python code that
uses a return statement for the tuple, e.g.

def X():
return 23, 42, 69

therefore you call it as, e.g.:

a, b, c = X()

would set a to 23, b to 42, c to 69. (You need to know how many
items are in the tuple X returns, to use this kind of assigment
which is called "unpacking assignment", because you need to list
exactly that number of targets on the left of the = sign).

I have had only the IDL and the py File from the IDL,
were stand take *args and return the return value.
In none of my python books such a construct is described. I'm sorry.

Thanks for helping me,


No problem, and you're welcome. I do understand that Python books
don't say much about Corba (I didn't myself in the Nutshell, and
there is just one very simple example in the Cookbook which does
not cover the cases of out and inout parameters). But if the books
don't cover *args and/or return-value packing and unpacking, then
you might want to get better books;-)
Alex

Jul 18 '05 #6
In article <bj************ *@news.t-online.com>,
Birgit Rahm <br**@yahoo.d e> wrote:
I've already read this, but I hoped, there is a way to get these out
parameters beside this.


Aside from all the help Alex has already given you, perhaps you should
have read the very next part of the specification, after the bit Piet
quoted. It says:

"""
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()
"""

I don't think it can get much clearer than that.

Cheers,

Duncan.

--
-- Duncan Grisby --
-- du****@grisby.o rg --
-- http://www.grisby.org --
Jul 18 '05 #7
On Thu, Sep 04, 2003 at 08:12:57AM +0200, 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


I found this result when searching for 'omniorbpy "out parameter"':
http://www.omniorb-support.com/piper...il/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.

| From: Duncan Grisby <dgrisby at uk dot research dot att dot com>
| Subject: [omniORB] omniORBpy out parameter passing issue
|
[...]
| Out arguments in the Python mapping appear as extra return values in a
| tuple. So, if you have IDL
|
| interface I {
| long op(in string a, out short b, inout double c);
| };
|
| Then to call op, you do
|
| (result, b, c) = i.op(a, c)
|
| I recommend that you read the mapping specification, which you can
| download from
|
| http://www.omg.org/cgi-bin/doc?ptc/00-01-12
|
| Cheers,
|
| Duncan.

Jeff

Jul 18 '05 #8
Birgit Rahm wrote:
Hallo Newsgroup,
Hi Birgit,
I have the following problem:
I work with Python 2.2 and invoke functions via CORBA ( I use
onmiORB/omniORBpy) on a server.
The server provides me a function, where the 3 arguments are out-arguments
and the return is void / None.
How can I get these out arguments? [...]


The out (or inout) parameters will be returned as return parameters of
the method. In your case there should be a 3-tuple of the out parameters
returned.

See the Python-IDL Language Mapping for details (search for "out
parameter" in this document):

http://www.python.org/wiki/pub/Corba...s/01-02-66.pdf

-- Gerhard

Jul 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2442
by: Chuck Anderson | last post by:
I have a function with 7 inputs. The last three have default values. I want to call that function specifying the first four, skip two and then specify the last. I thought I could write this as : $retval = myfunction(arg1, arg2, arg3, arg4,,,arg7); .... but Php does not seem to want to let me do this. I get a parse
9
3813
by: Matt Eberts | last post by:
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as a single argument? I'm sorry, this explanation is just atrocious, but I can't think of exactly how to word it. Maybe an example... Take for instance Function.apply. It takes 1-2 arguments, the first being the object to use as the context, and...
6
4025
by: Melkor Ainur | last post by:
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed from a user's program and use a C backend to evaluate the tree. I'm using Lex, Yacc and C. Now, there are some functions that are built into this language and others which are not. The problem I'm having is that I haven't found a way to represent...
21
4138
by: dragoncoder | last post by:
Consider the following code. #include <stdio.h> int main() { int i =1; printf("%d ,%d ,%d\n",i,++i,i++); return 0; }
41
2593
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum += arguments;
9
16849
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script type='text/javascript'> function myFunc(lev) { // if (lev) return myFunc(lev-1); var aStack=; nextFunc = arguments.callee;
7
1944
by: sfeher | last post by:
Hi All, Is there a way to preserve the arguments across functions? I have: <script> function myFirstFunction() { // arguments = 'param1'
36
2737
by: Pacific Fox | last post by:
Hi all, haven't posted to this group before, but got an issue I can't work out... and hoping to get some help here ;-) I've got a base object that works fine with named arguments when called on it's own. However when I call the child object I get an error " has no properties (in firefox)." I simple test:
7
3228
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the bastard so posting it before I forgot again... By taking this minimum code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head>
2
12558
ADezii
by: ADezii | last post by:
When a call is made to a Sub or Function Procedure, you can supply Arguments in the exact order they appear in the Procedure's definition, or you can supply them in any position by name. To illustrate this point, I'll use a fictitious Function called fCalculateInterest() which accepts 3 Arguments (Currency, Single, and Long) and returns a value of type Currency. Public Function fCalculateInterest(curPrincipal As Currency, sngRate As Single,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.