Confused about behaviour of base class
<p>This follows a question I asked a few hours ago. </p>

<p>I have this code:</p>

<pre><code>class A(object):
    def __init__(self, a):
        print 'A called.'
        self.a = a

class B(A):
    def __init__(self, b, a):
        print 'B called.'

x = B(1, 2)
print x.a
</code></pre>

<p>This gives the error: <code>AttributeError: 'B' object has no attribute 'a'</code>, as expected.  I can fix this by calling <code>super(B, self).__init__(a)</code>. </p>

<p>However, I have this code:</p>

<pre><code>class A(object):
    def __init__(self, a):
        print 'A called.'
        self.a = a

class B(A):
    def __init__(self, b, a):
        print 'B called.'
        print a

x = B(1, 2)
</code></pre>

<p>Whose output is: </p>

<pre><code>B called.
2
</code></pre>

<p>Why does this work? And more importantly, how does it work when I have not initialized the base class? Also, notice that it does not call the initializer of <code>A</code>. Is it because when I do a:</p>

<p><code>def __init__(self, b, a)</code></p>

<p>I am declaring <code>b</code> to be an attribute of <code>B</code>? If yes, how can I check <code>b</code> is an attribute of which class - the subclass or the superclass? </p>
