[SciPy-User] problems with numpy array assignment

Jonathan T. Niehof jniehof at lanl.gov
Tue Mar 4 15:55:18 EST 2014


On 03/04/2014 01:52 PM, Eric Hermes wrote:
> This is not true of python datatypes in general. For example:
>
> B = [...]
> A = B
>
> In this case A and B can be independently modifed without affecting each
> other.  This is because python lists are passed by value, unlike numpy
> arrays which are passed by reference.

 >>> a = [1, 2, 3]
 >>> b = a
 >>> b[1] = 99
 >>> a
[1, 99, 3]

Python variables are essentially references.

-- 
Jonathan Niehof
ISR-3 Space Data Systems
Los Alamos National Laboratory
MS-D466
Los Alamos, NM 87545

Phone: 505-667-9595
email: jniehof at lanl.gov

Correspondence /
Technical data or Software Publicly Available



More information about the SciPy-User mailing list