[IronPython] Modules in hosted enviroment

Jeff Hardy jdhardy at gmail.com
Mon Jun 21 17:24:48 CEST 2010


On Sat, Jun 19, 2010 at 10:51 PM, Ross Hammermeister <glitch17 at gmail.com> wrote:
> I have a project where I am hosting IronPython and I was wondering what is
> the best way to create modules in C# for python to use. I have found two
> ways to do it so far. One method is what is done in IronPython, where static
> classes and the PythonModule attribute are used but I don't want to use
> static classes to access runtime data.

I'm not 100% sure what you mean here, but the static class is just a
container - and it can contain non-static classes (and functions, and
static variables, etc). If it needs to be a module, it's the way to
go, as far as I'm concerned. If things get too big, don't forget that
you can use partial classes to split things up.

However, depending on what your code does, you probably don't need to
make it a module - IronPython will work just fine with any .NET class
library. Just do a `clr.AddReference` and then import the classes.

- Jeff



More information about the Ironpython-users mailing list