[CentralOH] PythonDotNet

Thomas Winningham winningham at gmail.com
Mon Feb 23 01:56:14 CET 2015


I had been thinking about this, and while I haven't messed with Python on
.NET, I have messed with C# some, as well as other Python on top of another
language type arrangements.

There must be either one of two things you can do, but the details of which
you may be on your own to investigate (sorry):

1. The Python.NET, being dynamically typed, must have some sort of
functions to support the static (and more specific) types of the .NET
system. This may be something that allows you to specifically create a C#
compatible array of unsigned shorts like that second parameter of the
function requires. I would imagine a study of the documentation for
Python.NET may well reveal some kind of capability like this as a language
support library or something similar. I know with say, Jython, it is called
Java Interop, same with Clojure on the JVM.

2. You could approach this the other way, and write some C# to wrap this
function in a function that does work with Python the way you want or
however you can get it to work, then in this new C# function, coerce the
types passed in to be an array of unsigned shorts, and pass that to the
original function.

Best of luck, and let us know if you find anything interesting.

Thomas


On Sat, Feb 21, 2015 at 10:10 PM, Mark Erbaugh <mark at microenh.com> wrote:

> Greetings,
>
> I am struggling with a hobby project using PythonDotNet.  I have an API
> for an external device written in C# and .NET.  I have the C# code. Rather
> than using IronPython, I am trying to use PythonDotNet with CPython 2.7.9.
> The C# code was not written with any special consideration of Python.
>
> The API implements callback functions. I have been able to write several
> of the callback functions in Python and they work. But, now I've come
> across something that I can't figure out, and perhaps it's not supported by
> PythonDotNet. There is a callback routine that passes a C# array of
> shorts.  the C# function signature is
>
>         public delegate void DataReadyEventHandler(Panadapter pan,
> ushort[] data);
>
> No matter how I try to code my Python function, I am getting a runtime
> exception from the PythonRuntime part of PythonDotNet.
>
> Is passing this array possible?
>
> Thanks,
> Mark
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20150222/8b1bc780/attachment-0001.html>


More information about the CentralOH mailing list