Explain how to copy an object in Python.



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

Post New Answer

More Python Interview Questions

Why python is the best?

0 Answers  


Explain the dictionary in Python.

1 Answers  


What is the use of the // operator?

0 Answers  


Can I learn python on my own?

0 Answers  


Do we need to call the explicit methods to destroy the memory allocated in python?

0 Answers  






Which is faster tuple or list?

0 Answers  


Explain inheritance in python with example?

0 Answers  


Draw a comparison between the range and xrange in python?

0 Answers  


Is Django written in Python?

0 Answers  


How do you sort a list in python?

0 Answers  


What are the ones that can be used with pandas?

0 Answers  


What is super in python class?

0 Answers  


Categories