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


Groups > comp.lang.python > #105194

Re: why x is changed in the following program?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: why x is changed in the following program?
Date Fri, 18 Mar 2016 11:37:16 +0100
Organization None
Lines 19
Message-ID <mailman.311.1458297456.12893.python-list@python.org> (permalink)
References <81574A74-81F6-44F3-8A42-EC3B12A2A399@telecom-paristech.fr>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de HOJ9p4JrGGauftYmPyeHjQg1IcCMmgOqqJiWT8afdL3g==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:why': 0.09; 'python': 0.10; 'modification': 0.15; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:program': 0.16; 'wrote:': 0.16; 'affects': 0.22; 'object.': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'header:X -Complaints-To:1': 0.26; 'random': 0.29; 'print': 0.30; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'subject:the': 0.39; 'skip:x 10': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd8b3b.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105194

Show key headers only | View raw


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]

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web