how to copy a Python object
mitsura at skynet.be
mitsura at skynet.be
Tue Feb 7 03:36:32 EST 2006
Hi,
I am new to Python and OO programming.
I need to copy a Python object (of a class I made myself).
new_obj = old_object doesn't seem to work since apparently new_obj is
then a referrence to old_obj.
I found out that there is a module called 'copy' that allows you to do
a shallow or a deep copy.
I need a deep copy since my object contains dicts to other objects that
also need to be copied.
However, when I do new_object = copy.deepcopy(old_object) I get a
series of errors. The most important one:
"
TypeError: object.__new__(PySwigObject) is not safe, use
PySwigObject.__new__()
"
So any help much appreciated.
With kind regards,
Kris
I am using Python 2.4
More information about the Python-list
mailing list