Explain how to copy an object in Python.
Answer / chaitanya
There are two ways in which objects can be copied in python.
Shallow copy & 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.
-copy.deepcopy(a) returns a deep copy of a.
| Is This Answer Correct ? | 0 Yes | 0 No |
Which db is best for python?
Can a constructor be static?
How memcached should not be used in your python project?
What is the function of a negative index?
What are python packages?
What are tuples in python? How differ with lists?
How to use decorators in Python?
What is difference between set and list in python?
What is the output of the following code and why?
Which module(s) of python can be used to measure the performance of your application code?
What is zip () in python?
Why is not__getattr__invoked when attr==’__str__’?