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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Which os is best for python?

440


How do you reverse the string in python?

477


What is zip() function in python?

452


Tell me how do you debug a program in python?

450


What is the best notepad?

445






What are class methods in python?

456


What does the meaning of slicing in python?

458


What is json? Describe in brief how you’d convert json data into python data?

467


Explain split(), sub(), sub() methods of “re” module in python?

519


Is python dictionary a hash table?

419


What is abstract class in python?

432


Why anaconda is used for python?

468


What is flask (__ name __)?

422


Write a program to find the max value from a list without using max()?

439


What are the disadvantages of using python?

416