[IronPython] Arrays in IronPython

Martin Maly Martin.Maly at microsoft.com
Mon Sep 25 17:28:52 CEST 2006


Array[int][int] is equivalent to Array[int]. Using this syntax, the type that takes effect is actually the type in the right-most brackets. For example:

Array[int][str] is equivalent to Array[str]

This is probably an unintentional (and admittedly confusing) behavior that we will look at fixing in the future releases.

Martin

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of David Anton
Sent: Friday, September 22, 2006 1:55 PM
To: users at lists.ironpython.com
Subject: Re: [IronPython] Arrays in IronPython


Thanks Dino.  That's cleared up Python jagged arrays for me.

Any idea what the "Array[int][int]" means?  Iron Python is ok with it, but I
can't figure out what it is (or how to initialize it).


Dino Viehland wrote:
>
> You can initialize the values on this like:
>
> Array[Array[int]]( ( (1,2), (2,3) ) )
>
> (any sequence will do here, e.g. a list work too).
>
> If you want to create a true multi-dimensional array you can do:
>
> x = Array.CreateInstance(int, Array[int]( (1,2,3)))
>
> And then you can fill the values by hand:
>
> x[0,1,2] = 2
>
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com
> [mailto:users-bounces at lists.ironpython.com] On Behalf Of David Anton
> Sent: Wednesday, September 20, 2006 8:15 AM
> To: users at lists.ironpython.com
> Subject: [IronPython] Arrays in IronPython
>
>
> After a lot of googling on this, I'm still confused about .NET arrays (not
> Python lists) in IronPython.
> One dimensional arrays are clear:
> foo = Array[int] ((1,2))
>
> But how to set up jagged arrays and multidimensional arrays?
>
> I know that IronPython is happy with the following (i.e., no error), but
> I'm not sure what they mean:
> foo = Array[int][int]
> foo = Array[Array[int]]
>
> The first one behaves just like Array[int], so I think IronPython is just
> ignoring the second "[int]" ?
> The second one would appear to me to be a jagged array, but how do I
> initialize it with values?
>
> --
> View this message in context:
> http://www.nabble.com/Arrays-in-IronPython-tf2306048.html#a6409948
> Sent from the IronPython mailing list archive at Nabble.com.
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>

--
View this message in context: http://www.nabble.com/Arrays-in-IronPython-tf2306048.html#a6454898
Sent from the IronPython mailing list archive at Nabble.com.

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list