Reputation: 762
I know that in python the memory "arrange" itself, but is there a way to determine in which way I want it ?
In primitive variable it duplicates the variable but in list etc. it make it by reference.
I have a class that has pygame Surface, some regular variables and things like that, now if I'll do a=b it will make a as pointer to b, how can I make it dupliacte it?
(I know I can make a function which does that but maybe there's an easier way)
Note that I have a whole class to copy, not only the Surface
Upvotes: 0
Views: 92
Reputation: 15446
You can use the copy
module:
import copy
Class MyClass():
def __init__(self):
self.val = 5
a = MyClass()
b = copy.deepcopy(a)
Upvotes: 2