Explain how to copy an object in Python.There are two ways in which objects can be copied in python:
1. Shallow copy
2. Deep copy
- Shallow copies duplicate as minute as possible whereas Deep copies duplicate everything.
- If a is object to be copied then copy.copy(a) returns a shallow copy of a. The copy.deepcopy(a) returns a deep copy of a.
- exception copy.error: It raises for module specific errors.
- Assignment statements in Python do not copy objects and they create bindings between a target and an object.