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

Brian Lloyd brian.lloyd at revolution.com
Sat Apr 21 00:27:28 CEST 2007

Hi Aaron - 

PythonNet tip 'o the day: you can probably just construct the array in
Python as a normal list:

  mylist = [[1, 2], [3, 4], ...]

If you pass that to a method with a signature that takes int[,] then
everything should Just Work so long as the lists and their contents
are actually convertible to the stated type ;)

The syntax you're using below is actually trying instantiate a
bound generic type (Array[int] is equivalent to Array<int> in C#),
so when you say 'Array[int](10)' it is trying to create the bound
generic type and initialize it with 10 (which is not an array),
which is probably not what you intended.

hope this helps,


On 4/20/07 4:59 PM, "Aaron Rubin" <Aaron.Rubin at 4DTechnology.com> wrote:

> Hi Alberto - 
> Thanks for your help!  Seems to work fine now....except...I am trying to
> use arrays.  I am following the README on the python for .NET website.
> Here are the commands I am trying to run:
> from System import Array # works!
> myarray = Array[int](10) # fails! TypeError: Cannot convert 10 to
> System.Int32[]
> I'm a little confused...obviously the example doesn't work, but how
> *should* arrays be initialized in Python .NET?  The c# code might look
> like:
> int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
> I'm actually looking to make a 2D array.  Further, the end goal is to
> make a 2D array...then serialize it....then deserialize it in c# code
> itself.  I'm hoping to make this a transport layer between Python and
> C#.  It's a bit complicated, but I have an existing application in
> Python which I want to get some calculated results out of without
> writing listeners, named pipes, web services, etc.  All I want to do is
> to serialize a .NET 2D array created in Python.
>  - Aaron
>> -----Original Message-----
>> From: pythondotnet-bounces at python.org
>> [mailto:pythondotnet-bounces at python.org] On Behalf Of Alberto Berti
>> Sent: Friday, April 20, 2007 1:49 AM
>> To: pythondotnet at python.org
>> Subject: Re: [Python.NET] Installing Python for .NET with .NET 2.0?
>> Hi Aaron,
>> the tarballs on pythondotnet's site are for .NET 1, if you
>> want to use it with .NET 2 you should checkout the last svn
>> trunk and patch it with the instruxtions described in this mail
>> http://thread.gmane.org/gmane.comp.python.dotnet/576 .In that
>> message there is also a link to binary packages provided by
>> Angel Ignacio.
>> Hi hope soon to set up a wiki dedicated to pythondotnet as
>> there aren't so many examples of using it for things like
>> embedding etc. I'm just looking for a wiki engine which as
>> some effective spam protection. If someone has any hint on a
>> product or a service please drop me a line.
>> Alberto
>> _________________________________________________
>> Python.NET mailing list - PythonDotNet at python.org
>> http://mail.python.org/mailman/listinfo/pythondotnet
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet

More information about the PythonDotNet mailing list