array from list of lists

Charles R Harris charlesr.harris at gmail.com
Mon Nov 13 00:18:22 CST 2006


On 11/12/06, Erin Sheldon <erin.sheldon at gmail.com> wrote:
>
> Hi all -
>
> Thanks to everyone for the suggestions.
> I think map(tuple, list) is probably the most compact,
> but the list comprehension also works well.
>
> Because map() is proably going to disappear someday, I'll
> stick with the list comprehension.
>   array( [tuple(row) for row in result], dtype=dtype)
>
> That said, is there some compelling reason that the array
> function doesn't support this operation?


My understanding is that the array needs to be allocated up front. Since the
list comprehension is iterative it is impossible to know how big the result
is going to be.

BTW, it might be possible to use fromfile('name', dtype=dtype) to do what
you want if the data is stored by rows in a file.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061112/591667ae/attachment-0001.html 
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list