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

What super does in python?

0 Answers  


How to remove whitespaces from a string in python?

0 Answers  


How do I get a list of all files (and directories) in a given directory in Python?

0 Answers  


Is python 0 based?

0 Answers  


Which python course is best?

0 Answers  






Describe how to implement Cookies for Web python.

1 Answers  


Explain about odbc and python?

0 Answers  


Does python interact with database?

0 Answers  


Which method will be used to delete a file ?

0 Answers  


What is the input function in python?

0 Answers  


What is the use of try, except, finally and raise in error handling?

0 Answers  


Define the support for apex that exists?

0 Answers  


Categories