Feb-16-2020, 10:14 AM
Hello jrauden,
This is because function "show()" does not return anything (= None). So when you do:
This is because function "show()" does not return anything (= None). So when you do:
print(msg + ':', self.show())... it will print:
Output:A message : None
To get a more satisfying result you may change your code like this:class Simple: def __init__(self, str): print("Inside the Simple constructor") self.s = str def show(self): return(self.s) def showMsg(self, msg): print(msg + ':', self.show()) # Calling another method if __name__ == "__main__": # Create an object: x = Simple("constructor argument") print(x.show()) x.showMsg("A message")
Output:Inside the Simple constructor
constructor argument
A message: constructor argument