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
Is it worth to learn python in 2019?
What is difference between range and arange function in python?
What is frozen set in python?
What is the input function in python?
Which is faster python or php?
What are python slots?
What is use of set in python?
What are the disadvantages of Python Recursion?
How do you reverse any string in python?
How is Python used in web development?
Is python good for beginners?
What is abstraction in python?
What are metaclasses and what do we use them for?
Does python do until loop?
How long can an identifier be in python?