How can I add to the initial definition of a python class inheriting from another class?
<p>I'm trying to define <code>self.data</code> inside a class inheriting from a class</p>

<pre><code>class Object():
    def __init__(self):
        self.data="1234"

class New_Object(Object):
    # Code changing self.data here
</code></pre>

<p>But I ran into an issue.</p>

<pre><code>class Object():
    def __init__(self):
        self.data="1234"
</code></pre>

<p>So I have the beginning class here, which is imported from elsewhere, and let's say that the class is a universal one so I can't modify the original at all.</p>

<p>In the original, the instance is referred to as "<code>self</code>" inside the class, and it is defined as self inside the definition <code>__init__</code>.</p>

<pre><code>class New_Object(Object):
    # Code changing self.data here
</code></pre>

<p>So if I wanted to inherit from the class <code>Object</code>, but define self.data inside <code>New_Object</code>, I thought I would have to define <code>__init__</code> in <code>New_Object</code>, but this overrides the <code>__init__</code> from <code>New_Object</code></p>

<p>Is there any way I could do this without copypasting the <code>__init__</code> from <code>Object</code>?</p>

<p>That's what <a href="https://docs.python.org/2/library/functions.html#super" rel="nofollow"><code>super</code></a> is for:</p>

<pre><code>class NewObject(Object):

    def __init__(self):
        super(NewObject, self).__init__()
        # self.data exists now, and you can modify it if necessary
</code></pre>

python class inheritance instance