it is really easy to copy object with all attributes to another object in python. All you need to import copy library.
ex:
import copy
class Test:
def __init__(self,name):
self.name=name
def main():
a=Test('madura')
b=copy.deepcopy(a)
This will copy Test class object a, to Test class object b with the attribute values
ex:
import copy
class Test:
def __init__(self,name):
self.name=name
def main():
a=Test('madura')
b=copy.deepcopy(a)
This will copy Test class object a, to Test class object b with the attribute values
0 comments:
Post a Comment