[IronPython] IP 2: Execute multiple expression in different scopes

Dino Viehland dinov at microsoft.com
Tue Aug 19 08:50:14 PDT 2008

Is there a reason ObjectOperations.Call(scope.GetVariable("Process"), args) doesn't work?  Once you have the function in hand you can call using this and it takes a params array.  That params array will be splatted for the call expanding to however many arguments there are there.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Christian Schmidt
Sent: Tuesday, August 19, 2008 7:50 AM
To: dody at nomadlife.org; Discussion of IronPython
Subject: Re: [IronPython] IP 2: Execute multiple expression in different scopes

Hi Dody,

thanks for your patience.

> delegate System.Int32 FunctionProcess(System.Int32[] parameters)
> This assumes that your Python implement will only do integer operation.
> If you are going to use the delegate for generic holder of arguments,
> don't forget to cast
> for example:
> delegate object FunctionProcess(object[] parametser)
> python = @"
> def myItems(myParams)
>     val1 = Int(myParams[1])
>     val2 = Int(myParams[2])
>     return val1 + val2
> "
> You pretty much need to take care of the conversion. I don't think
> "*params object[]* "is supported on the hosting DLR because IronPython
> doesn't support this construct.

I'd say in python this is def f(*arg) and def f(**dict), or not?

Probably I need the "params object[]"-approach, because I'll use the
argument's name and not index.

The question is, how a PythonFunction can be casted to a delegate of a
certain type or if that is not possible, how can the PythonFunction be
called from C#?


Users mailing list
Users at lists.ironpython.com

More information about the Users mailing list