Is there a reason why you have to explicitly call a base-class constructor within the derived-class constructor? Why isn't this done automatically, like in C++? It seems to me that this is inconsistent with the economy of Python that you've shown in this chapter. For that matter, the same could be said about explicitly passing the self argument.
Hmm... Looks like python has some problems (atleast in windows) printing the output as expected ....
I have python 2.2 and the output of the code is...
Inside Simple2 constructor
Inside the Simple constructor
Called from display(): Overridden show() method
Simple2 constructor argument
Overridden show() method
Simple2 constructor argument
Inside main: Overridden show() method
Simple2 constructor argument
Overridden show() method
Simple2 constructor argument
Not derived from Simple
Note the line....
Called from display(): Overridden show() method
is in one line and so is ...
Inside main: Overridden show() method
The show() called from showMsg() is not the base-class version. Why? It will allow the derived-class change the base-class behavior in complete ignorance when I just want to override show() but expect the behavior of showMsg() is not changed.
"Simple2 is inherited from Simple, and in the constructor, the base-class constructor is called"
What about multiple inheritance? What's the syntax for calling the base classes constructors?
Hai!
I wanted to know how executed the script, in a standalone machine ie in the python interpreter ,
I was not able to execute ..
Well,I am new to any type of programming but I think that someone missed warning :# Overriding a base-class method.
As I see it the base class version of show()was overriden by
defining method again in subclass (with different output).You can test this by removing def show() block.