class assignment copy
tiddlerdeja at my-deja.com
tiddlerdeja at my-deja.com
Mon Jan 3 14:37:29 EST 2000
Sorry for the lame question.
If I have a class Foo:
class Foo:
def __init__(self):
self.bar = 1
If I create one instance of the class:
x = Foo()
How do I make a copy of x?
y = x
Just makes y refer to x, so if I change bar on y the value is also
changed on x.
I realise this is a lame question, I just couldn't find any python
material on this.
Do I need to create some copy constructor on the class?
Any help appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list