Python - C# interoperability

Luis M. González luismgz at
Wed Jan 10 04:50:57 CET 2007

mc wrote:
> Is there an easy way to compile a Python class (or set of classes) into
> a .DLL that a C# program can call?  Or otherwise to use an existing
> library of Python classes from a C# program as seamlessly as possible?

I'm affraid this is not possible.
Ironpython (the .NET python implementation) can consume assemblies
written in other statically typed languages, such as c#, but not the
other way around.
This is because Ironpython is still a dynamic language, and the lack of
type information makes it impossible to be compiled as c#.

For the time being, if you really need to write reusable assemblies
that could be consumed from other .NET languages, you shouldn't use
You should use c#, or any other static language implementation
for .NET.

If you want a more "pythonic" alternative, you could use Boo ( ).
It's a static language with a python-like syntax, and it's very easy to
pick up if you already know python.

For consuming Boo assemblies from Ironpython, you should compile them
as .DLL, and place them into a "DLLs" folder in your Ironpython root
directory (where ipy.exe is located).
Then you simply import them as you would with any other python module.
Make sure to add also the boo assembly. If you are using c# instead,
you don't have to add anything else.

Hope this helps,

More information about the Python-list mailing list