[SciPy-user] switch columns

Alan G Isaac aisaac at american.edu
Fri Nov 26 14:42:15 CST 2004


Suppose in Scipy I have a 2x2 array A and I
want to switch the first two columns.
I incorrectly expected the following to work:
A[:,0],A[:,1]=A[:,1],A[:,0]

Then I discovered this works:
A=mat(A)
A[:,0],A[:,1]=A[:,1],A[:,0]

Question: Why the difference?
And: how to anticipate this difference?

Thank you,
Alan Isaac




More information about the SciPy-user mailing list