[IronPython] Modules in hosted enviroment

Dino Viehland dinov at microsoft.com
Wed Jun 23 00:56:39 CEST 2010

Jeff wrote:
> Hi Ross,
> It sounds like you want Dino's suggestion IAttributesCollection, which
> will give you much more flexibility. I've never done that, but it
> looks fairly straightforward.
> > An unrelated issue I have with ScriptScope is I can't figure out to add
> > overloaded functions with different parameter counts for defaults I'm using
> > 3.5 if it matters.
> Dino?

I assume what you have here is a bunch of static methods declared somewhere and
you want to publish them in the scope?  The only way to really go about doing
this is getting the BuiltinFunction object for them and then publishing that
in the scope.  To get the BF you'll need to first get the PythonType and then
get the BF.  Such as:

public class MyObjectModel {
	public static void Foo() {

	public static void Foo(object x) {

Using C# 4.0 then I think you could do:

dynamic foos = ((dynamic)DynamicHelpers.GetPythonTypeFromType(typeof(MyObjectModel))).Foo;

or you could do:

object foos = engine.Operations.GetMember(DynamicHelpers.GetPythonTypeFromType(typeof(MyObjectModel))), "Foo");

More information about the Ironpython-users mailing list