[IronPython] importing C# functions

Stefan Rusek s at rusek.org
Sat Aug 5 15:01:27 CEST 2006


Tell him to look into using IronPython instead of normal python. IP is
written completely in C# and has really good .net support, and he should be
able to declare a static method and use it like normal function in python.

--Stefan

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Saturday, August 05, 2006 7:37 AM
To: users at lists.ironpython.com
Subject: Re: [IronPython] importing C# functions


Slide wrote:
> I am currently adding a scripting console to one of the applications I
> develop. I would like to, at runtime, add functions that can be called
> by the python code in the console. Something like
>
> // c#
> public int AddIt(int a, int b)
> {
>     return a + b;
> }
>

Does C# allow you to define functions outside of objects ? I didn't
think so...

You can create static methods on objects though.

> then, I would like to add that function (and possibly functions from
> plugins) so they can be called from python. Do I need to create a
> module and add the functions to the module? Is there a better way?
>

For an example of creating a dll from C#, and then accessing from
IronPython, see :

http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e406

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> Thanks,
>
> slide
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list