Questions to the FAQ
seefeld at sympatico.ca
Tue Jul 13 22:46:33 CEST 2004
Josef Wolf wrote:
> - FAQ entry 6.5: "What is delegation?"
> AFAICS, the example in this FAQ-entry should create a derived class from
> the file class. Therefore, shouldn't the first line of this class
> definition read "class UpperOut(file):"?
no, because that wouldn't be delegation but inheritance. Delegation is
*not* about subclassing, but about delegating a task to another object.
> How come self.__outfile to be the base class?
> - FAQ entry 6.6:
> This FAQ entry makes a difference between new-style classes and classic
> classes. An example is given for the new style and a hint is given how a
> classic class would look like. But I can't see any difference in them:
> The new-style example starts with "class Derived(Base):" and the hint for
> the classic class is "class Derived(Base): ..." So what's the difference?
the example is about how an overridden method can call the base-class
method. For both cases the same child/parent relationship is assumed.
The difference is in the spelling of "call the base' class method",
which, with new-style classes uses 'super'.
More information about the Python-list