Classes, Objects, Inheritance?
<p>I'm supposed to create three classes: a parent, and child 1 and child 2.<br>
Child 1 and 2 are supposed to inherit from the Parent class. 
So I believe I've done that. </p>

<pre><code>class Parent:
    """Parent Object"""

    def __init__(self):
        self.greeting = "Hi I'm a Parent Object!"


class ChildA(Parent):

    def __init__(self):
        childclass.__init__(self)
        self.childgreeting = "Hi I'm a Child Object!"


class ChildB(Parent):
    pass
</code></pre>

<p>Now I have to write a parent object and the children objects which will print out their respective strings.<br>
That's where I'm getting confused: I already put in the strings that they are a child or parent object within their classes.<br>
But how do I get them to print as an object?</p>

<p>I've started out my code like this. </p>

<pre><code>class Parent(object):

class ChildA(object):

class ChildB(object):
</code></pre>

<p>How to get those strings to print is bugging me.<br>
And I have a feeling that my ChildA code for the class is not correct either.</p>

<p>Can anyone help me?</p>

<pre><code>class Parent(object):

    def __init__(self):
        self.greeting = "Hi I am a parent"
    def __str__(self):
        return self.greeting


class Child(Parent):

    def __init__(self):
        super(Child, self).__init__()
        self.greeting = "Hi I am Child"

    def __str__(self):
        return self.greeting


p = Parent()
print(p)
c = Child()
print(c)
</code></pre>

<p>This method could help you to use 'print()' statement to print out greeting for individual class. But if you want to directly get self.greeting attribute you should use </p>

<pre><code>p = Parent()
print(p.greeting)
</code></pre>

<p>Hope I understood you since your questions seems to be not properly explained...</p>

python class object inheritance