What are the commands that are used to copy an object in Python?



What are the commands that are used to copy an object in Python?..

Answer / chaitanya

The command that is used to copy an object in python includes:

• copy.copy() function: This makes a copy of the file from source to destination. It returns a shallow copy of the parameter that is passed.

• copy.deepcopy(): This also creates a copy of the object from source to destination. It returns a deep copy of the parameter that is passed to the function.

The dictionary consists of all the objects and the copy() method which is used as:

newdict = olddict.copy()

The assignment statement doesn’t copy any object but it creates a binding between the target and the object that is used for the mutable items. Copy is required to keep a copy of it using the modules that is provided to give generic and shallow operations.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Python or r: which one would you prefer for text analytics?

1 Answers  


Does Python support enums?

1 Answers  


Do you know how is multithreading achieved in python?

1 Answers  


Mention five benefits of using python?

1 Answers  


Please explain in python what is slicing?

1 Answers  


What is the command to debug a python program?

1 Answers  


What does means by “call by reference” in python?

1 Answers  


How do I parse xml in python?

1 Answers  


What does all do in python?

1 Answers  


Which web server is best for python?

1 Answers  


How do we share global variables across modules in Python?

1 Answers  


What are membership operators in python?

1 Answers  


Categories