I was reading about Python Docs and came in this paragraph, which I am not sure about:
Derived classes can override the methods of their base classes. Since there is no special privilege in ways to call other methods of identical objects, a method of base class that calls another method defined in the same base class, can call the method of the derivative class that it Override. (For C ++ programmers: All the methods in Python are effectively virtual.)
Example:
Class A: def foo (self) : Self.bar) DEF bar (printed): "A to" class B (A): def AFU (self): itself .bar () Def bar (self): Print "From B"
Does this mean that any object of class A
There is no way that superclass can know anything about subclass This is that if you instantiate subclass B, and it processes a method foo ()
, and overrides one method to bar ()
, then When you call foo ()
, which will give the definition of bar ()
, definition in A is not bar ()
definition. This superclass writer does not intend - the bar ()
was expected to call for his definition.
Comments
Post a Comment