copy an object
John J. Lee
jjl at pobox.com
Wed Jun 25 21:23:14 EDT 2003
yuvalfeld at hotmail.com (Yuval) writes:
> I have an object of a class I wrote myself, and now I want to copy it.
[...]
john[0]$ python
Python 2.3b1 (#2, May 2 2003, 11:43:06)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy
>>> help(copy)
>>> # also...
>>> lst = [1,2,3]
>>> newlst = lst[:]
>>> newlst[1] = "spam"
>>> print newlst
[1, 'spam', 3]
>>> print l
[1, 2, 3]
John
More information about the Python-list
mailing list