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
Which is better perl or python?
How will you uit the python?
Draw a comparison between the range and xrange in python?
How do you get all values from a python dictionary?
Convert a string representation of list to list.
Differentiate *args and **kwargs?
What is python inheritance?
How do you sort in descending order in python?
What is raise keyword do in python exception handling?
Does python have class?
How to write multiple statements in a single line in python?
Which python memory profiler is recommended?
How to read a 10gb (or larger) file size in python?
Can a set be sorted python?
Which library would you prefer for plotting in python language: seaborn or matplotlib?