shallow copy's
Mark McEahern
marklists at mceahern.com
Fri Jul 5 15:24:14 EDT 2002
> a = [1,2,3,4]
> b = a
>
> Do some operations on a
> Will the contents of b mirror a? Or will b remain unchanged?
Why not answer the question yourself? Welcome to the Joy of Python:
$ python
Python 2.2.1 (#1, Jun 25 2002, 10:55:46)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = range(5)
>>> b = a
>>> a
[0, 1, 2, 3, 4]
>>> b
[0, 1, 2, 3, 4]
>>> b.append("foo")
>>> a
[0, 1, 2, 3, 4, 'foo']
>>> b
[0, 1, 2, 3, 4, 'foo']
Does that answer your question?
// m
-
More information about the Python-list
mailing list