inheritance using parent class method without calling parent class
<p>Is there any way to access parent class method, without actually calling the class?</p>

<p>e.g.:</p>

<p>1)</p>

<pre><code>class A():
    def __init__(self):
        print('A class')

    def name():
        print('name from A class')
</code></pre>

<p>2)</p>

<pre><code>class B(A):
    # I want to make use of name without actually calling or running A.
    # Is there any way to do that?
</code></pre>

<p>Yeah, you can just call it directly. This works fine:</p>

<pre><code>class A():
    def __init__(self):
        print('A class')

    def name(self):
        print('name from A class')

class B(A):
    pass

B().name()

&gt; A class
&gt; name from A class
</code></pre>

<p>You can also use it inside of the class, like </p>

<pre><code>class B(A):
    def b_name(self):
        print('I am B!')
        self.name()
</code></pre>

<p>If what you're trying to get around is calling A's <code>init</code>, then maybe you should turn <code>name</code> into a classmethod:</p>

<pre><code>class A():
    def __init__(self):
        print('A class')

    @classmethod
    def name(self):
        print('name from A class')

A.name()

&gt; name from A class
</code></pre>

<p>Alternatively, you can give B an <code>init</code> which doesn't call its super class, thus instantiating it without calling A's init. I don't particularly recommend this method:</p>

<pre><code>class A():
    def __init__(self):
        print('A class')

    def name(self):
        print('name from A class')

class B(A):
    def __init__(self):
        print('B class')

    def b_name(self):
        print('b_name from B class')
        self.name()

B().b_name()

&gt; B class
&gt; b_name from B class
&gt; name from A class
</code></pre>

python inheritance