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 |
What are the runtime errors?
Explain me what is the purpose of doc strings in python?
How to implement an 'enum' in python?
What do you mean by overriding methods?
What is web scraping?
What is the dogpile effect?
Why python is so popular?
What do you mean by *args and **kwargs?
What is the difference between deep and shallow copy?
How to run script in python?
How do you define xrange in python 3?
What is import in python?