[Python.NET] Installing Python for .NET with .NET 2.0?

Alberto Berti alberto at metapensiero.it
Sat Apr 21 02:12:38 CEST 2007


>>>>> "Aaron" == Aaron Rubin <Aaron.Rubin at 4DTechnology.com> writes:

Hi Aaron,

    Aaron> from System import Array # works!  
    Aaron> myarray = Array[int](10) # fails! TypeError: Cannot....

the correct semantic is myarray = Array[int]((0,1,2,3,4,5,6,7,8,9))

    Aaron> I'm a little confused...obviously the example doesn't work,
    Aaron> but how *should* arrays be initialized in Python .NET?  The
    Aaron> c# code might look like: int[,] numbers = new int[,] { {1,
    Aaron> 2}, {3, 4}, {5, 6} };

i wasn't able to find the correct way to create an instance of a
multidimensional Array... i think that actually it is not possible,
but maybe someone can correct me here.

    Aaron> I'm actually looking to make a 2D array.  Further, the end
    Aaron> goal is to make a 2D array...then serialize it....then
    Aaron> deserialize it in c# code itself.  I'm hoping to make this
    Aaron> a transport layer between Python and C#.  It's a bit
    Aaron> complicated, but I have an existing application in Python
    Aaron> which I want to get some calculated results out of without
    Aaron> writing listeners, named pipes, web services, etc.  All I
    Aaron> want to do is to serialize a .NET 2D array created in
    Aaron> Python.

I'm at the very start of my Python embedding journey, but since now i
prefer to work with native Python objects on that side, and then deal
with messy stuff at the messy level (read c#). So list and tuples
become PyList, PyTuples and you can iterate or convert them
appropriately. I do not know however if that is the correct way to do
such things.....

hope it helps

Alberto


More information about the PythonDotNet mailing list