[Tutor] assignment statements in python
kermit at polaris.net
Mon Jun 12 04:14:37 CEST 2006
Date: Sun, 11 Jun 2006 06:58:39 -0400
From: Kent Johnson <kent37 at tds.net>
Subject: Re: [Tutor] buggy bug in my program
Cc: tutor at python.org
Assignment in Python is not a copy, it is a name binding. Assignment
creates a name for an object. If you assign the same object to two
names, they both are bound to the same thing. If the object is mutable,
like a list, changes to the object will be seen regardless of which name
you use to refer to it.
I feel a little bit better now that I know that there is a reason for what
However, I still don't have any idea how to copy values from one cell in
an array to the adjacent cell in the same array.
I looked at the reference ,
that you gave,
but did not gleam any hint from it how to copy values from one place in an
array to another place within the same array.
It must be possible, for otherwise, you could not sort an array.
It is quite remarkable that my not knowing that
assignment is not a copy
gave me no difficulties before now.
Kermit < kermit at polaris.net >
More information about the Tutor