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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord Sent: Saturday, August 05, 2006 7:37 AM To: [email protected] 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 > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
