class Foobar(object):

    def __init__(self, value):
        self.value = value


class FoobarMixin(object):

    def __init__(self, **kwargs):
        foobar = kwargs['foobar']
if isinstance(foobar, Foobar):
    self.foobar = foobar
else:
    self.foobar = Foobar(foobar)


class Foo(FoobarMixin):

    def __init__(self, value, **kwargs):
        super(Foo, self).__init__(**kwargs)
self.value = value
print(self.value, self.foobar)


class Bar(FoobarMixin):

    def __init__(self, value, **kwargs):
        super(Bar, self).__init__(**kwargs)
self.value = value
print(self.value, self.foobar)
foo = Foo('foo', foobar='foobar')
bar = Bar('bar', foobar=Foobar('foobar'))
How can I make __init__ take a new value or an existing instance?