[Numpy-discussion] initializing an array of lists

alan@ajackso... alan@ajackso...
Sun Nov 8 18:11:30 CST 2009


>On 11/7/2009 10:56 PM, alan@ajackson.org wrote:
>> I want to build a 2D array of lists, and so I need to initialize the
>> array with empty lists :
>>
>> myarray = array([[[],[],[]] ,[[],[],[]]])  
>
>
>[[[] for i in range(3)] for j in range(2) ]
>
>fwiw,
>Alan Isaac

Thanks! I like that - concise and a little strange. 8-)


-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan@ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------


More information about the NumPy-Discussion mailing list