Extending a black box python module
<p>I have a "blackbox" python module which I would like to extend. The module provides a class <code>class Foo</code> with no <code>__init__</code> function, and a helper function <code>FooMaker</code> which returns objects of type <code>Foo</code>. The usual strategy of extending modules:</p>

<pre><code>class ExtendedFoo(blackbox.Foo):
    def __init__(self, x):
        super(ExtendedFoo, self).__init__(x)
</code></pre>

<p>would not work here, since, as mentioned above I need to rely on <code>blackbox.FooMaker</code> instead of <code>Foo</code>'s <code>__init__</code> function.</p>

<p>Any ideas on how to extend the module <code>blackbox</code>?</p>

<p>This should do the same as your solution but is a bit shorter:</p>

<pre><code>from blackbox import Foo, FooMaker

class ExtendedFoo(Foo):

    def __init__(self, *args, **kwargs):
        self.set(FooMaker(*args, **kwargs).get())
</code></pre>

python python-2.7 cython