copy an object
I have an object of a class I wrote myself, and now I want to copy it.
How do I do it? The reason I want to copy it is because if I simply
use copied_object=existing_object, when I later change
"copied_object", "existing_object" is changed as well, and I dont want
it to happen.
Re: copy an object
email@example.com (Yuval) writes:
> I have an object of a class I wrote myself, and now I want to copy it.
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
>>> # also...
>>> lst = [1,2,3]
>>> newlst = lst[:]
>>> newlst = "spam"
>>> print newlst
[1, 'spam', 3]
>>> print l
[1, 2, 3]
|All times are GMT. The time now is 01:19 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.