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

What does sort () do in python?

0 Answers  


What is __ doc __ in python?

0 Answers  


What is python literal?

0 Answers  


Is c++ easier than python?

0 Answers  


Is javascript better than python?

0 Answers  


Explain Python's data types.

2 Answers  


What is %s in python?

0 Answers  


What does time time () do in python?

0 Answers  


What is the script in python?

0 Answers  


Does python have enums?

0 Answers  


When would you use a break statement in a for loop?

0 Answers  


What do u mean by instance?

0 Answers  


Categories