Ben Chuanlong Du's Blog

It is never too late to learn.

Copy Object in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

You can use the copy module to copy objects in Python. Customized coping behavior can be achived by overriding the methods __copy__ (for shallow copy) and __deepcopy__ (for deep copy).

References

https://docs.python.org/3/library/copy.html#copy.deepcopy

https://stackoverflow.com/questions/4794244/how-can-i-create-a-copy-of-an-object-in-python

Comments