[Python.NET] Calling Python functions/objects forom C# code
Kyle Rocha
kyle.rocha at gmail.com
Sun Jul 7 21:14:40 CEST 2013
Hey this is excellent, however after swapping to your branch from Tony
Roberts', It seems that a string returned from .net yields a list
rather than a string.
/ kyle
On 3 July 2013 07:32, Patrick Stewart <patstew at gmail.com> wrote:
> Avi Mitrani <avi.m at ...> writes:
>
>> I’m new to PythonDotNet, and to integrating Python & C#, and I have to say
> that I’m ‘breaking my teeth’
>
>> Is there an example or tutorial you can direct me to?
>
> You need to do something like:
> var res = PyTuple.AsTuple(fibmodule.InvokeMethod("fib2", new PyObject[1] { new
> PyFloat(10) }));
> double r = (double)res.GetItem(0).AsManagedObject(typeof(double));
>
> This sucks, so I've made some modifications so that python can be called from
> C# just like normal code, without all the hassle of .GetAttr and .Invoke.
> Using my version of pythondotnet you can just run:
>
> double r = fibmodule.fib2(10);
>
> and it does the right thing.
> You can find it here: https://github.com/patstew/pythonnet
>
> Cheers,
> Patrick
>
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
More information about the PythonDotNet
mailing list