Problem with assignment. Python error or mine?

Neil Cerutti neilc at norwich.edu
Thu Dec 21 10:19:20 EST 2017


On 2017-12-21, rafaeltfreire at gmail.com <rafaeltfreire at gmail.com> wrote:
> Dear community, I am having the following problem when I am
> assigning the elements of a vector below a certain number to
> zero or any other value. I am creating a new variable but
> Python edits the root variable. Why?
>
> import numpy as np
>
> X=np.arange(1, 10000, 1) #root variable

np.arange creates an object. The assignment makes X refer to that
object.

> x1=X 

X refers to the previous object, and then the assignment makes x1
refer to that same object.

-- 
Neil Cerutti




More information about the Python-list mailing list