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 |
How does a function return values?
How to call a function of a module by using its name (a string)?
Can you write an efficient code to count the number of capital letters in a file?
Can dictionary have a duplicate keys ?
Which is faster python or c?
Is python interpreted, or compiled, or both?
What is a CGI script in Python?
What does len () mean in python?
What does super () mean in python?
How to get a list of class attributes in python?
What are python variables?
What is the syntax for exponentiation and give example?