The typical way to do subclassing in Python is this
class Base:
def __init__(self):
self.base = 1
class Sub(Base):
def __init__(self):
self.sub = 2
super().__init__()
And this allows me to create an instance of type Sub that can access both base
and sub
properties.
However, I'm using an api that returns a list of Base
instances, and I need to convert each instance of Base
into an instance of Sub
. Because this is an API that is subject to change, I don't want to specifically unpack each property and reassign them by hand.
How can this be done in Python3?