# your code goes here
class A1:
def __init__(self, a, b):
self.a = a
self.b = b
self.c = 10
def pnt1(self):
for prop in dir(self):
if prop.startswith('__') and prop.endswith('__'):
continue
if hasattr(self, prop):
print(prop)
print(getattr(self, prop))
print("A1")
class A2:
def __init__(self, a, b):
self.a = a
self.b = b
self.c = 12
self.d = 34
def pnt2(self):
for prop in dir(self):
if prop.startswith('__') and prop.endswith('__'):
continue
if hasattr(self, prop):
print(prop)
print(getattr(self, prop))
print("A2")
a = A1(5, 6) # a = 5, b= 6, c = 10
b = A2(1, 2) # a = 1, b = 2, c = 12, d = 10
def copy_properties(source, target):
for prop in dir(source):
if prop.startswith('__') and prop.endswith('__'):
continue # Skip built-in properties
if hasattr(target, prop):
print('LOL :')
print(prop)
setattr(target, prop, getattr(source, prop))
print("CP")
a.pnt1()
b.pnt2()
copy_properties(a, b)
b.pnt2()
# b.pnt1()
print(b.d)
a
5
b
6
c
10
pnt1
<bound method A1.pnt1 of <__main__.A1 object at 0x14b84f13bd00>>
A1
a
1
b
2
c
12
d
34
pnt2
<bound method A2.pnt2 of <__main__.A2 object at 0x14b84f13b550>>
A2
LOL :
a
LOL :
b
LOL :
c
CP
a
5
b
6
c
10
d
34
pnt2
<bound method A2.pnt2 of <__main__.A2 object at 0x14b84f13b550>>
A2
34