[IronPython] Call methods from Python-Script

Eichhorn, Georg Georg.Eichhorn at philips.com
Thu Aug 27 10:32:59 CEST 2009


Hi,

I found my problem - thanks for the help Dino. CClassName was not public. Now it works fine.

Greetings,
Georg

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Mittwoch, 26. August 2009 18:46
To: Discussion of IronPython
Subject: Re: [IronPython] Call methods from Python-Script

Is CClassName a public type?  It'll need to both have public members and also be public its self.

If that's not the problem I'm having trouble understanding exactly what's going on.  Is "return class.doSomething(parameter)" supposedly Python code?  Or are you doing this from C#?  "class" is a keyword in Python so I don't see how it's Python code.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Eichhorn, Georg
Sent: Tuesday, August 25, 2009 11:00 PM
To: users at lists.ironpython.com
Subject: [IronPython] Call methods from Python-Script

Hi,

I have implemented some piece of code that should execute a python-script. In this script I want to call a c#-function.
First, I Generate a module (context to work in):

 _scriptRuntime.Start(true);
 _scriptRuntime.ScriptScope.SetVariable("class", this); ('this' is CClassName')

Then I get the class:

PythonType pType = _scriptRuntime.ScriptScope.GetVariable("CClassName") as PythonType;

Create an instance of the object

_Class = _scriptRuntime.ScriptScope.Engine.Operations.CreateInstance(pType, new object[] { });

[...] (do some other tings)

>From the python script, I want to call the function:

return class.doSomething(parameter)

The code throws an exception:

'CClassName' object has no attribute 'doSomething'.

What am I making wrong? CClassName has a public method doSomething()

Thanks for U're help.

Greetings
Georg Eichhorn

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090827/cf6e8874/attachment.html>


More information about the Ironpython-users mailing list