[Numpy-discussion] Re: array of arbitrary objects

Robert Kern robert.kern at gmail.com
Wed May 10 20:43:01 EDT 2006


Albert Strasheim wrote:

> How does one go about putting tuples into an object array?

Very carefully.

In [2]: a = empty(3, dtype=object)

In [3]: a
Out[3]: array([None, None, None], dtype=object)

In [4]: a[:] = [(1,2), (2,3), (3,4)]

In [5]: a
Out[5]: array([(1, 2), (2, 3), (3, 4)], dtype=object)

In [6]: a.shape
Out[6]: (3,)

-- 
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





More information about the NumPy-Discussion mailing list