To get a fully independent copy of an object you can use the copy.deepcopy()
function.
For more details about shallow and deep copying please refer to the other answers to this question and the nice explanation in this answer to a related question.
More Related Contents:
- Spawning multiple instances of the same object concurrently in python
- How do I call a parent class’s method from a child class in Python?
- What is the difference between __init__ and __call__?
- Why is `object` an instance of `type` and `type` an instance of `object`?
- How to make a copy of a 2D array in Python? [duplicate]
- Python object attributes – methodology for access
- In Python, when are two objects the same?
- How to access object attribute given string corresponding to name of that attribute
- What is the difference between old style and new style classes in Python?
- What is the difference between shallow copy, deepcopy and normal assignment operation?
- What are the differences between type() and isinstance()?
- Meaning of @classmethod and @staticmethod for beginner? [duplicate]
- What is the __del__ method and how do I call it?
- Explaining Python’s ‘__enter__’ and ‘__exit__’
- Using the class as a type hint for arguments in its methods [duplicate]
- How can I separate the functions of a class into multiple files?
- How do I initialize the base (super) class?
- Understanding the difference between __getattr__ and __getattribute__
- “public” or “private” attribute in Python ? What is the best way?
- What does object’s __init__() method do in python? [duplicate]
- Python: how to “kill” a class instance/object?
- Copy constructor in python?
- How can I access “static” class variables within methods?
- How do I set and access attributes of a class? [duplicate]
- Why do ints require three times as much memory in Python?
- How do you change the value of one attribute by changing the value of another? (dependent attributes)
- Fast way to copy dictionary in Python
- Python – Testing an abstract base class
- How to replace an instance in __init__() with a different object?
- How can two Python objects have same id but ‘is’ operator returns False?