[IronPython] Calling a Python function with passed in args/kwargs from C#

Jeff Hardy jdhardy at gmail.com
Sat Apr 24 00:53:07 CEST 2010

I'm trying to call a Python function from C# using args/kwargs from
the C# function, like so:

    public void Frob(CodeContext context, [ParamDictionary]IDictionary
kwargs, params object[] args)
        context.LanguageContext.Operations.Invoke(foo, args, kwargs);

foo is a Python callable object - in this case it's just:

    def foo(*args, **kwargs):
        print args
        print kwargs

so that I can what is actually passed to it.

I'd like to call foo with the equivalent of Python's foo(*args,
**kwargs). Passing it the way I did above just passes the arguments
into args without expanding them. Is there any way to trigger the
argument expansion from C#?

- Jeff

More information about the Ironpython-users mailing list