[Tutor] super constructor usage

Rafael Knuth rafael.knuth at gmail.com
Thu Mar 30 07:39:08 EDT 2017

>> > I am trying to wrap my head around the super constructor.

Is it possible to embed a super constructor into an if / elif
statement within the child class?

if message == "string A": return X
elif: return Y

How should I modify my code below?
(I couldn't solve that by myself)

class A:
    def __init__(self, message):
        self.message = message

class B(A):
    def __init__(self, message):
        print("This is the message from your parent class A:")
        super(B, self).__init__(message)


More information about the Tutor mailing list