[Numpy-discussion] list dtype?

Mark Wendell mark.wendell@gmail....
Sun Jul 19 17:19:04 CDT 2009


Sorry for being a newbie about it, but could you provide an example?

I was able to do this:

d = np.dtype( {'names':['mylist'], 'formats':[np.object]})
but I'm not sure if that's the correct way to produce a python list-type dtype.

Further, how do I then define a new array with that as a dtype?

When I do this:
a = np.array( (5,5), dtype = d)
I get the error:
ValueError: size of tuple must match number of fields.


Any help appreciated. Thanks!
Mark

On Sun, Jul 19, 2009 at 2:37 PM, Robert Kern<robert.kern@gmail.com> wrote:
> On Sun, Jul 19, 2009 at 11:22, Mark Wendell<mark.wendell@gmail.com> wrote:
>> Is it possible to create a dtype that is a list of arbitrary length?
>
> Use the object dtype.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
--
Mark Wendell
"I guess songs are just interesting things to do with the air." Tom Waits


More information about the NumPy-Discussion mailing list