I have this kind of structure:
class Foo:
def __init__(self, val1):
self.val1 = val1
def changeToGoo(self)
HOW???
class Goo(Foo):
def __init__(self, val1, val2):
super(val1)
self.val2 = val2
a = Foo(1)
a.changeToGoo()
'a' is now an instance of Foo
now i would like to change it to be an instance of Goo, by using the method "changeToGoo", and add the other value.
How can this be done in Python?
I have tried:
self.__class__ = Goo
but when I check:
type(a)
it's still Foo, and not Goo.