i have a structure like,
class Foo(object):
def __init__(self, value=True):
if value:
Bar()
else:
Zoo()
pass
class Bar(Foo):
pass
class Zoo(Foo):
pass
z = Foo(True) # instance of Foo() class
when i instantiate the class Foo() it will return the instance of Foo class, but i want it should return the instance of Bar or Zoo class(ie. any class which is called according to the value supplied to Foo class)
Thanks in advance
That’s exactly what
__new__()is for: