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 are the differences between c and python?

0 Answers  


Why does the following behave unexpectedly in python?

0 Answers  


How to find bugs or perform static analysis in a python application?

0 Answers  


How do I run notepad ++ in python?

0 Answers  


Explain python variable scope error?

0 Answers  






explain the reduce() function?

0 Answers  


What is python api?

0 Answers  


Why should I learn python in 2019?

0 Answers  


Where python is mostly used?

0 Answers  


What module is used to execute linux commands through the python script and give us with one example

0 Answers  


Python documentation is called?

0 Answers  


What is docstring? How to define it?

0 Answers  


Categories