I think you want the copy module
import copy
x = copy.copy(y) # make a shallow copy of y
x = copy.deepcopy(y) # make a deep copy of y
you can control copying in much the same way as you control pickle.
More Related Contents:
- How to copy files?
- How do I clone a list so that it doesn’t change unexpectedly after assignment?
- What is the difference between shallow copy, deepcopy and normal assignment operation?
- How to deep copy a list?
- What is the difference between `sorted(list)` vs `list.sort()`?
- Understanding dict.copy() – shallow or deep?
- difference between variables inside and outside of __init__()
- Pandas: Chained assignments [duplicate]
- How can I create a copy of an object in Python?
- How to overload __init__ method based on argument type?
- Chain-calling parent initialisers in python [duplicate]
- Instance attribute attribute_name defined outside __init__
- Does a slicing operation give me a deep or shallow copy?
- How does Python’s “super” do the right thing?
- Python constructor and default value [duplicate]
- How to copy worksheet from one workbook to another one using openpyxl?
- Is there a way to instantiate a class without calling __init__?
- Copy multiple files in Python
- How to make a completely unshared copy of a complicated list? (Deep copy is not enough)
- How to copy directory recursively in python and overwrite all?
- python copy files by wildcards
- __init__() missing 1 required positional argument
- Why does object.__new__ work differently in these three cases
- __init__ as a constructor?
- Why updating “shallow” copy dictionary doesn’t update “original” dictionary? [duplicate]
- How to make a copy of a 2D array in Python? [duplicate]
- Python: Inherit the superclass __init__
- Calling superclass constructors in python with different arguments
- Restarting a thread in Python
- Copy complete virtualenv to another pc