[Numpy-discussion] create numerical arrays from strings

RayS rays at blue-cove.com
Sat Feb 8 20:44:32 EST 2014

At 05:46 AM 2/6/2014, Alan G Isaac wrote:
>Compare np.mat('1 2; 3 4')
>to np.array([[1, 2], [3, 4]])
>for readability and intimidation factor.
>Little things matter when getting started
>with students who lack programming background.

my $.02:
>'1 2; 3 4'
is a non-obvious and non-intuitive way to describe a 2D array or 
matrix - and try explaining later that the values are actually stored 
in memory as 1,3,2,4 and why and watch the freshman chins drop...

 >>> np.array([[1,2],
...           [3,4]])
array([[1, 2],
        [3, 4]])
Why use both significant whitespace and punctuation to separate elements?

I've billed many months rewriting old Matlab code into Python - 
please don't saddle future engineers with a closed, non-objective, 
expensive product based on FORTRAN and written in C that breaks old 
code with every release. </rant>
There are so many fine, easy tutorials like 

- Ray

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140208/5a1c4958/attachment.html>

More information about the NumPy-Discussion mailing list