[SciPy-user] switch columns

Alan G Isaac aisaac at american.edu
Fri Nov 26 15:42:15 EST 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