Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105194 > unrolled thread

Re: why x is changed in the following program?

Started byPeter Otten <__peter__@web.de>
First post2016-03-18 11:37 +0100
Last post2016-03-18 11:37 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: why x is changed in the following program? Peter Otten <__peter__@web.de> - 2016-03-18 11:37 +0100

#105194 — Re: why x is changed in the following program?

FromPeter Otten <__peter__@web.de>
Date2016-03-18 11:37 +0100
SubjectRe: why x is changed in the following program?
Message-ID<mailman.311.1458297456.12893.python-list@python.org>
maurice.charbit@telecom-paristech.fr wrote:

> from numpy import random
> x=random.randn(6)

In Python 

> y=x

doesn't make a copy, it binds y to the same object as x. From now on every 
modification you apply to y

> y[0]=12

 affects x, too, because x and y refer to the same object.

> print x[0]

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web