I have a code (simplified):
class A(object):
attrib1 = "a"
attrib2 = "b"
class B(A):
flag = True
in some place in my code, I have an instance of A, but I need to create an instance of class B, which will have all the data from instance of A… I feel myself stupid, but I don’t want to do something like:
class B(A):
def __init__(self,a1,a2,a3,a4,..):
self.a1 = a1
self.a2 = a2
and call like:
obj_b = B( obj_a.a1, obj_a.a2,...)
1 Answer