why x is changed in the following program?
Palpandi
palpandi111 at gmail.com
Fri Mar 18 14:55:24 EDT 2016
More information about the Python-list mailing list
Fri Mar 18 14:55:24 EDT 2016
- Previous message (by thread): why x is changed in the following program?
- Next message (by thread): submodules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Friday, March 18, 2016 at 3:53:58 PM UTC+5:30, maurice... at telecom-paristech.fr wrote: > from numpy import random > x=random.randn(6) > y=x > y[0]=12 > print x[0] > > > > Maurice Charbit > Emeritus Prof. > mob.: 33 (0)6 5230 1171 > tel.: 33 (0)1 4581 7178 > fax: 33 (0)1 4581 7144 > maurice.charbit at telecom-paristech.fr <mailto:maurice.charbit at telecom-paristech.fr> > Adresse: > Institut Mines-Telecom, > 46, rue Barrault, 75014 Paris http://stackoverflow.com/questions/6793872/variable-assignment-and-modification-in-python if a = 5 b = a print id(a) == id(b) >> False b = 2 print a >> 5 In this case we assigning the value to b. But in the above case, we are assigning the same object reference. Like arrays in c.
- Previous message (by thread): why x is changed in the following program?
- Next message (by thread): submodules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list